Thanks to visit codestin.com
Credit goes to github.com

Skip to content

🐛 fix(nushell): surface actionable hint in deactivate error output#3112

Merged
gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:main
Apr 9, 2026
Merged

🐛 fix(nushell): surface actionable hint in deactivate error output#3112
gaborbernat merged 4 commits into
pypa:mainfrom
gaborbernat:main

Conversation

@gaborbernat
Copy link
Copy Markdown
Contributor

@gaborbernat gaborbernat commented Apr 9, 2026

When users activate via use activate.nu * or with a custom overlay name (overlay use activate.nu as foo), calling deactivate fails with nushell's "not an active overlay" error. The error message pointed at the alias line but gave no guidance on what went wrong or how to fix it.

overlay hide is a parser keyword whose argument is validated at parse time. Implementing deactivate as a def would fail at file-load time because the overlay does not exist yet when the def body is compiled — nushell validates the name when the file is first parsed as part of overlay use activate.nu, before the overlay is actually registered. The alias is the only correct mechanism: it defers the expansion of overlay hide activate to call time, when the overlay is active.

nushell includes one line of context above the error site in its output. 💡 Placing a hint comment directly above the deactivate alias therefore makes the guidance appear inline in the error every affected user sees, with no documentation lookup required:

 90 | # If deactivate errors "not an active overlay": activate with `overlay use activate.nu` not `use activate.nu *`; for custom names use `overlay hide NAME`
 91 | export alias deactivate = overlay hide activate
    :                                        ^^^^^^^^ not an active overlay

The header comment is also tightened to explicitly warn against use ... *. Closes #3103.

When users activate via `use activate.nu *` or with a custom overlay
name (`overlay use activate.nu as foo`), calling `deactivate` fails with
nushell's "not an active overlay" error. The error message pointed at the
alias line but gave no guidance on what went wrong or how to fix it.

`overlay hide` is a parser keyword whose argument is validated at parse
time. Implementing `deactivate` as a `def` instead of an alias would fail
at file-load time because the overlay doesn't exist yet when the def body
is compiled. The alias is the only correct mechanism: it defers the parse
of `overlay hide activate` to call time, when the overlay is active.

nushell includes one line of context above the error site in its output.
Placing a hint comment directly above the alias therefore makes the
guidance appear inline in the error every user actually sees, without
requiring them to read any documentation.

Also tightens the header comment to explicitly warn against `use ... *`
and extends test_nushell to assert both failure scenarios produce the
expected error text.

Fixes pypagh-3103
gaborbernat and others added 3 commits April 8, 2026 22:12
…ript

Two Python subprocess calls for the pypagh-3103 regression were awkward
alongside the existing ActivationTester infrastructure. Moving them into
a dedicated test that uses a single nushell script with ^nu | complete
keeps the assertions in nushell-native code and cuts the Python overhead
to one process invocation.
@gaborbernat gaborbernat enabled auto-merge (squash) April 9, 2026 05:36
@gaborbernat gaborbernat merged commit d00c465 into pypa:main Apr 9, 2026
115 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: canot deactivate on nushell

1 participant