Repository navigation
Make error output for missing environment variables more specific - #19529
Merged
Merged
Conversation
Accessing an unset environment variable with `$env.FOO` used to raise `nu::shell::column_not_found`, with a help hint about rows and the `default` command that doesn't apply to environment variables. The `LoadEnv` instruction now returns the existing `EnvVarNotFoundAtRuntime` error instead, which resolves the FIXME left in `eval_ir.rs`. Tests that asserted the old column error for env lookups are updated to expect the new error. Closes nushell#8543 Co-Authored-By: Claude Opus 5.5 <[email protected]>
lucperkins
force-pushed
the
env-var-not-found-error
branch
from
November 13, 2026 22:38
0959329 to
83e2da9
Compare
fdncred
reviewed
Nov 14, 2026
Contributor
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
$env.FOO now reports env_variable_not_found with the $env.FOO? hint everywhere I tried it: closures, def, each, do, and arguments to run and %$cmd. Two nits on the hint text are left.
Findings: 0
Notes from my clanker, checked on 83e2da9. Built the branch and ran each case on the branch binary and on 0.117.1 (main 7bff3d1). CI's clippy, tests and typos are green on this head, so I didn't rerun them.
Contributor
|
Thanks |
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.



Description
Fixes #8543 by changing the error output for a missing environment variable to be more developer friendly.
Currently:
Proposed:
User-facing changes (Release notes)
Accessing an unset environment variable, like
$env.UNSET_VAR, now raises anu::shell::env_variable_not_founderror rather than the more genericnu::shell::column_not_founderror, and suggests using a construction like$env.UNSET_VAR?for optional access.Additional notes
N/A