🐛 fix(nushell): surface actionable hint in deactivate error output#3112
Merged
Conversation
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
…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.
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When users activate via
use activate.nu *or with a custom overlay name (overlay use activate.nu as foo), callingdeactivatefails 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 hideis a parser keyword whose argument is validated at parse time. Implementingdeactivateas adefwould 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 ofoverlay use activate.nu, before the overlay is actually registered. The alias is the only correct mechanism: it defers the expansion ofoverlay hide activateto 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
deactivatealias therefore makes the guidance appear inline in the error every affected user sees, with no documentation lookup required:The header comment is also tightened to explicitly warn against
use ... *. Closes #3103.