You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bash-env-nushell directly runs the separately installed bash-env-json executable and parses its JSON output into a Nushell record. That output includes changed values, null for unset variables, and changes to PATH or PWD. The current pattern:
bash-env ./environment.sh | load-env
does not fully translate the delta into Nushell semantics:
null becomes nothing instead of removing the variable.
Bash PATH is a string, while Nushell normally uses a list.
Nushell rejects assigning PWD through load-env; it must be applied with cd.
Proposal
bash-env ./environment.sh | bash-env apply
Keep bash-env unchanged for capture and inspection. bash-env apply would consume its record and:
map null/nothing to hide-env --ignore-errors;
convert PATH using Nushell's environment conversion, with the platform separator as fallback;
apply PWD with cd;
pass remaining values to load-env.
This likely requires an exported def --env. Accepting a record also lets users inspect or transform a delta before applying it.
Those changes could simplify the adapter, but bash-env-nushell can implement the mappings now. PWD will probably remain an adapter-level translation to cd.
The README already lists unsetting as future work.
Thanks for raising this. There are certainly some considerations here.
Here are my initial thoughts.
I think load-env itself should handle null/ nothing as unset variable. Obviously would need this proposal to be taken to the core Nushell team, but my feeling is that is the right solution.
PATH handling I am unsure about. Is the current behaviour that Nushell itself doesn’t notice the new path, but any child processes do? If so isn’t that also arguably a mis-feature in Nushell core which should be fixed there (also in load-env)?
I think PWD should be filtered out by bash-env-json and simply not appear in the output. I would be happy to make such a change there. The point is, cd is simply out of scope for what an environment file is reasonably expected to do.
Yes 😁
Trying to give you an early reply as I’m otherwise pretty tied up this week sorry. Hopefully this suggests alternative solutions for you?
For load-env handling null or nothing as an unset variable, I agree now that this is a better fit in Nushell core. There’s nushell/nushell#15872, which covers explicit unset flags but doesn’t cover treating nothing as removal, so I’ll bring this up over there in core.
For PATH handling, Nushell sees the change. which finds new commands from the updated PATH and they execute. Child processes also receive the updated PATH. Only $env.PATH changes from a list to a string. Nushell’s Direnv guide tells users to convert PATH after load-env to restore its usual list form. This issue would affect any external environment importer, so Nushell core providing an explicit conversion option that applies $env.ENV_CONVERSIONS may make the most sense. I’ll raise that upstream too.
Filtering PWD would be better in bash-env-json. I agree. That prevents load-env from rejecting the entire delta. As an extra wrinkle, OLDPWD can change with it, so filtering both avoids inconsistent directory state.
I’ll leave this open for now and reevaluate what this issue should actually be scoped to after those things are resolved.
status with Nushell 0.116.1 and bash-env-json 0.11.0:
Directory variable filtering is fixed upstream. bash-env-json #19, released in 0.11.0, filters PWD, OLDPWD, and DIRSTACK. I confirmed that changing directories in the Bash input no longer causes load-env to reject the delta.
PATH normalization is available in Nushell core. Nushell #18832 makes refreshing ENV_CONVERSIONS also restore PATH to its usual list form.
Unset semantics remain unresolved in Nushell core. Nushell #15872 remains open. load-env still keeps keys with nothing values in $env, although child processes don't receive them. Actual removal still requires hide-env.
When the imported Bash environment changes PATH, load-env leaves it as a string. The second line restores it to a Nushell list and applies configured environment conversions.
Activity
tesujimath commentedon Jul 28, 2026
Thanks for raising this. There are certainly some considerations here.
Here are my initial thoughts.
load-envitself should handle null/ nothing as unset variable. Obviously would need this proposal to be taken to the core Nushell team, but my feeling is that is the right solution.PATHhandling I am unsure about. Is the current behaviour that Nushell itself doesn’t notice the new path, but any child processes do? If so isn’t that also arguably a mis-feature in Nushell core which should be fixed there (also inload-env)?PWDshould be filtered out bybash-env-jsonand simply not appear in the output. I would be happy to make such a change there. The point is,cdis simply out of scope for what an environment file is reasonably expected to do.Trying to give you an early reply as I’m otherwise pretty tied up this week sorry. Hopefully this suggests alternative solutions for you?
Thanks for your interest!
TyceHerrman commentedon Jul 29, 2026
Very helpful!
For
load-envhandling null ornothingas an unset variable, I agree now that this is a better fit in Nushell core. There’s nushell/nushell#15872, which covers explicit unset flags but doesn’t cover treatingnothingas removal, so I’ll bring this up over there in core.For PATH handling, Nushell sees the change.
whichfinds new commands from the updated PATH and they execute. Child processes also receive the updated PATH. Only$env.PATHchanges from a list to a string. Nushell’s Direnv guide tells users to convert PATH afterload-envto restore its usual list form. This issue would affect any external environment importer, so Nushell core providing an explicit conversion option that applies$env.ENV_CONVERSIONSmay make the most sense. I’ll raise that upstream too.Filtering
PWDwould be better inbash-env-json. I agree. That preventsload-envfrom rejecting the entire delta. As an extra wrinkle,OLDPWDcan change with it, so filtering both avoids inconsistent directory state.I’ll leave this open for now and reevaluate what this issue should actually be scoped to after those things are resolved.
tesujimath commentedon Aug 1, 2026
The PWD aspects of this are now fixed in tesujimath/bash-env-json#19, released as bash-env-json 0.11.0.
TyceHerrman commentedon Oct 15, 2026
status with Nushell 0.116.1 and bash-env-json 0.11.0:
PWD,OLDPWD, andDIRSTACK. I confirmed that changing directories in the Bash input no longer causesload-envto reject the delta.ENV_CONVERSIONSalso restore PATH to its usual list form.load-envstill keeps keys withnothingvalues in$env, although child processes don't receive them. Actual removal still requireshide-env.When the imported Bash environment changes PATH, load-env leaves it as a string. The second line restores it to a Nushell list and applies configured environment conversions.
pattern needs documenting and a regression test
Separately, project's
bash-env-jsonpin dependency could use an update to bring in the directory filtering fix from 0.11.0 (will open pr for this)