-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
nix-daemon.sh in zsh gives priority to system binaries on macOS #4169
Comments
I don't use ZSH so I'm not super familiar with the details here and am just speaking from what I recall of other issues, but this sounds like a pickle. IIRC ZSH users frequently complain that macOS updates overwrite zshrc and "break" Nix. I'm not sure how often this actually happens. The hope in the change to zshenv was that Apple would leave it alone since it doesn't exist. I can think of at least 2 more options here, but I'm not sure what the consequences of either would be:
@LnL7 @matthewbauer @lilyball anyone know more about these, or have other ideas? |
It actually seems like all of
By default path_helper is used from |
I don't know if they're literally overwriting these files with the unmodified contents on each update (or if these changes only happen when Apple actually updates the zsh files, but are happening more regularly lately because Apple is still consolidating issues with making it the default shell?) but:
It looked like everything in paths.d is also appended to the end of the PATH list, so I think /etc/paths is the only way to the front without either disabling path_helper or modifying the setting afterwards. There's probably also some way to use a hook/trap to set the PATH later, but I'm not familiar with the ZSH options here. |
@surajbarkale may also have some idea of what's going on here. |
I believe I've suggested this in a different ticket before, but I think The risk is if I have a shell environment that's initialized before nix-daemon. Normally
I expect I also think Having said that, when was the last time Apple actually moved these files aside? If Apple is still overwriting these files with new updates, as opposed to merely having done so in the past, then really the best solution is to file a ticket with Apple to get them to stop blowing away changes to these files. |
I never checked whether
I very much agree. In fact, I think everything in Nix install script should be enforced on every boot or even more often, so that we can:
NixOS is great at pushing configuration management to every aspect of every machine. I think Nix of Mac should at least take care of its own configuration in similar way. |
This is a workaround for macOS's path_helper stuff in /etc/zprofile: - NixOS/nix#4169 - LnL7/nix-darwin#122
I marked this as stale due to inactivity. → More info |
Not stale, same issue here. Although, I do have nix-daemon being sourced in zshrc, and am still having the issue. |
Could we just restore it to /etc/zshrc in the meantime? Try: #5179 |
This reverts commit 909d8cb. This messes up PATH priority since /etc/profile gets sourced AFTER /etc/zshenv and it sets the system paths so $HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin is behind /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. See discussion in NixOS#4169.
+1 for the #5179 from me as well. I was unable to find another suitable fix for the issue. |
No strong reason not to, I guess. I worry a little that reverting to the old status quo will make it easier to drop it from the 2.4 milestone and kick the can on the underlying problem of macOS clobbering these files. But as I meditate on it, I guess a simple reversion is also the most-likely result if this actually ended up blocking release... |
I think the proper long-term solution to the files being clobbered is for nix-daemon to check for this and repair it on launch. |
Fixed in #5179. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/system-version-of-command-in-path-until-i-reload-my-shell/16677/7 |
Describe the bug
After #3608
nix-daemon
is being sourced from/etc/zshenv
instead of/etc/zshrc
which leads to system binaries getting priority over ones installed in Nix profile.Steps To Reproduce
nix-env -iA nixpkgs.git
git
Expected behavior
Git should run from Nix.
nix-env --version
outputAdditional context
The order of files run by zsh is:
/etc/zshenv
and~/.zshenv
/etc/zprofile
and~/.zprofile
/etc/zshrc
and~/.zshrc
/etc/zprofile
on macOS contains a call to/usr/libexec/path_helper
that overrides PATH variable prepending all system paths from/etc/paths
file and/etc/paths.d
dir. Before #3608nix-daemon.sh
was sourced in/etc/zshrc
after this call and Nix paths were in the front of the resulting PATH variable. After #3608 it is sourced in/etc/zshenv
which leads to Nix paths ending up in the very end of PATH.The text was updated successfully, but these errors were encountered: