-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PATH variable keeps growing in nested shells #11
Comments
The script has its own guard at the top, but it doesn't export the guard and so fish cannot see it. This means subshells don't see the guard either. The script probably should be updated to export the guard, although nix-env.fish still wouldn't see it as it only grabs paths starting with Probably the best solution is to get an upstream patch for nix-daemon.sh that actually makes it check if the paths it wants are in As a side note, NixOS (and nix-darwin) export their guard variables, but they're overriding a lot more of the environment and so suppressing that on subshells is a good idea. nix-daemon.sh on the other hand only sets Nix-specific variables and so rerunning that on subshells should be fine as long as it's idempotent (which appears to just require checking |
I suppose nix-env.fish could export the guard variable itself, but I don't consider that a good solution, and it wouldn't work for single-user installs anyway as the single-user profile doesn't have a guard variable (unless nix-env.fish adds its own guard variable check too). I would much prefer to see this fixed upstream instead. |
I filed this as NixOS/nix#5950. |
Thanks for this thoughtful response and quick action, much appreciated. |
Wanted to add a note that this is causing problems for me in development shells. For example, I have nodejs 16.x in my profile via nix-env, if I enter a |
@jhillyerd What happens if you run a nested If an interactive bash shell reproduces this (and your environment is still set up such that just running a new terminal with a bash login shell initializes Nix, i.e. If bash is set up for Nix correctly but running an interactive bash subshell does not have this problem, that would be good to know. |
@lilyball I've just run into the same issue. If I |
@lilyball I use a mix of machines, some are NixOS. You are correct though, this particular one is WSL2 Ubuntu w/ Nix. Thanks for the heads up on the fish module, I'll check that one out for my NixOS box. Testing:
|
@jhillyerd, I can confirm, exploring the same kind of issue on wsl |
Thank you for this plugin.
I've just noticed that in nested shells, the PATH variable continues to grow.
I'm not sure if this should be considered a bug with nix-env.fish or with the script that nix-env.fish sources and replays. In my case, I'm running a multi-user install on MacOS and nix-env.fish is sourcing the nix-daemon.sh script.
Here is the relevant snippet from this plugin:
Here is the relevant snippet from nix-daemon.sh:
I'm able to "fix" the problem by updating nix-daemon.sh to check for duplicates:
But notice the script already has its own guard at the top, which doesn't work for us. So should this be guarded against by nix-env.fish, or is it something we need to push upstream? Thanks!
The text was updated successfully, but these errors were encountered: