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
{{ message }}
Repository navigation
macOS updates often break nix installation (updates replace path-hooks on multi-user install) #3616
I have noticed that every once and a while /Users/andrewmckinlay/.nix-profile/bin and /nix/var/nix/profiles/default/bin disappear from my $PATH. The last time this happened, the hook nix installed was missing from /etc/zshrc.
Copying the following hook (copied from /etc/bashrc) to /etc/zshrc and restarting the shell fixed everything again:
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
My concern is that macOS updates will periodically overwrite /etc/.zshrc (and /etc/.bashrc), requiring effort on my part to reinstall nix. For example, one macOS update overwrote the entire file to fix this misspelling:
andrewmckinlay@imac ~ % diff /etc/zshrc.backup-before-nix /etc/zshrc
3c3
< # Setup user specific overrides for this in ~/.zhsrc. See zshbuiltins(1)
---
> # Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
Both files are read-only anyway, should they really be written to by the nix installer?
Reacted by Nathan Shelly, Tate Johnson, Sri Kadimisetty, Samuel Ainsworth, Oliver Rice, Thomas Wu, tsukimizake, 🐽を画面いっぱいに出力してみて, Daniel Almaguer, Nils Andre and 83 more
changed the title [-]macOS updates often break nix installation (multi-user install)[/-][+]macOS updates often break nix installation (updates replace path-hooks on multi-user install)[/+]on May 24, 2020
If they keep updating these files, perhaps we should file an Apple Feedback report asking them to add /etc/bashrc.d/ and /etc/zshrc.d folders whose contents get sourced by the default scripts? This way we can add configuration there that won't get overridden.
Beyond that, the only automatic solution that comes to mind would be to have nix-daemon check these files on launch and re-add the Nix block if it's missing.
Reacted by James Qualls, dannyongtey and Bernard Paulus
I have done a few days before the upgrade to Catalina 10.15.6... and today I wanted to install something to discover that my nix installation was gone!
Well after some research, I found that the /nix was still there, but everything else was gone... no nix-env command nothing!
So after cursing a lot... I search until I found this thread...
I would like also that this problem to solved... For the moment, I have put on my 2 users the following lines in the ~/.profile
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
So I don't care if the /etc/zshrc is or not overwritten in the future... I agree this is a bad solution, but at least for the time being my workaround...
Reacted by Tate Johnson, Solomon, Aron Adler, Oliver Rice, Seanmclem, Felix Uhl, Francesc Esplugas, gabby, Jost, PedroRegisPOAR and 7 more
I'm still seeing this issue as of Nix 2.3.15 and Big Sur 11.5.2. The workaround is to re-add the following to /etc/zshrc:
# Nixif [ -e'/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ];thensource'/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'fi# End Nix
Reacted by Samuel Ainsworth, Vrushali Raut, Jesús Martínez, tusing, Thiago Perrotta, Andrew Condon, Jason M., 110416, Francesc Esplugas, gabby and 42 more
I'm still seeing this issue as of Nix 2.3.15 and Big Sur 11.5.2.
Edit: I see in matrix that #3608 caused its own problems documented in #4169, so I guess a release would actually be a step in the wrong direction atm... Striking through the parts that may not actually be much help...
Even after a new release is cut from master, I expect you'll continue to see this behavior on an old install until you manually migrate or manually remove Nix and reinstall it.
I would try manually migrating. I think you'd just need to create /etc/zshenv if it doesn't exist, move your source line there, and verify it works.
Also: brownie points if you (or maybe any zsh user who hasn't taken 11.5.2 yet?) remember to report back here or in #3608 if this migration helps you dodge this problem.
@ggPeti I assume it's ideal if it still works without Nix-darwin, but tbh I have no clue how big the set of (Nix + zsh - nix-darwin) uses is.
#4169 seems to have a more robust discussion on ~zsh-specific fixes, and I'm trying to fish around for someone to add it to the 2.4 milestone; if I find someone, that might be a good place to pull on the thread...
Please deprecate nix on macOS until this issue is fixed.
Reacted by Reuben Gardos Reid, Thiago Kenji Okada, Salar Rahmanian, Jake Kreider, Felix Uhl, David Vo, Pavel Atanasov, Nate Meyer, Fatih Altinok, Ryan Mulcahy and 16 more
Please deprecate nix on macOS until this issue is fixed.
You are free to not use it for your own needs, but given there is a workaround, I'd disagree with your suggestion. It would be more constructive to investigate and suggest ways we could resolve this to the benefit of the community as a whole. Additionally this only impacts upgrade time and not general runtime.
Reacted by Fatih Altinok, Jake Kreider, Ryan Mulcahy, Udi Trugman, Gen, David Vo, Klemens Graf and Suraj
I'm having hard time making my r&d adopt nix on macOS due to this issue. They all stop use nix and go to homebrew installations after every macOS update.
Thank you very much @elliot-u410 and @amckinlay I've already went through a re-install on Mac this year, and just hit nix-shell:63: command not found: nix-shell again after updating to Sequoia 15.4. With this hook everything works as expected!
Until we have a solution that survives macOS updates, I suggest removing the part of updating /etc/zshrc (and the Bash counterpart?) from the macOS installer. Reasons:
For new users, this misleads them instead of helping them. They would think that the commands are available because it works when they try the examples immediately after installation. After a while they would notice that they somehow lose access to those commands, and will get very confused what have broken it.
For experienced users, like people above commenting how they “fixed” their own problem, they don’t need this (patching /etc/zshrc) anyway. So this isn’t helping them, either.
Instead of patching /etc/zshrc, if we simply tell users to source that script from their shell config (like ~/.zshrc or ~/.bashrc), it is only a very little friction (if any at all) for new users. Advantage of this approach:
This is strictly better than the current situation: some users benefit, while others are not hurt.
I recently moved to using Determinate for my Nix Shell, based on a friend's recommendation (he spends more time with system administration than I do).
I'll need to see how well this survives system updates, so I can't say at this point whether it is a "better" approach. I also haven't investigated the installation to see what it may do differently.
in programs.zsh.initExtra (with homemanager), I've never had any issues anymore.
I can confirm that the solution works - my Macbook just got a system update and nix works after that. Although I've used programs.zsh.initExtraFirst to make sure that this will always be on top of .zshrc file.
I just upgraded from MacOS 26 to 26.1 and it broke the Nix install (official nixos.org installer).
I can confirm that just re-installing is a workaround, but the installer fails if Nix is already installed because it wants to back up /etc/bashrcand /etc/bash.bashrc, and can't safely do so because it doesn't want to overwrite the old backup that the previous installer created.
Moving these files around manually enables the installer to go through without further problems.
All in all, a workaround exists, but it's kind of a cumbersome solution, and it would be great if something could be done to make the experience more user-friendly.
Happened to me today. Updating from 26.3 to 26.3.1 Official nix installer. Commands are gone, files are not. However, the bashrc file has the lines nix installer added, zshrc not.
Reacted by Faïz Hernawan, Daniel M., jonathangryphon, Mr_Melovdy and Max
Happened to me as well. I am not running nix-darwin, and only run home-manager. I see that for nix-darwin, this is fixed by DeterminateSystems/nix-installer#672.
Activity
[-]macOS updates often break nix installation (multi-user install)[/-][+]macOS updates often break nix installation (updates replace path-hooks on multi-user install)[/+]lilyball commentedon Jul 16, 2020
If they keep updating these files, perhaps we should file an Apple Feedback report asking them to add
/etc/bashrc.d/and/etc/zshrc.dfolders whose contents get sourced by the default scripts? This way we can add configuration there that won't get overridden.Beyond that, the only automatic solution that comes to mind would be to have
nix-daemoncheck these files on launch and re-add the Nix block if it's missing.ptitvert commentedon Jul 23, 2020
I have done a few days before the upgrade to Catalina 10.15.6... and today I wanted to install something to discover that my nix installation was gone!
Well after some research, I found that the /nix was still there, but everything else was gone... no nix-env command nothing!
So after cursing a lot... I search until I found this thread...
I would like also that this problem to solved... For the moment, I have put on my 2 users the following lines in the ~/.profile
So I don't care if the /etc/zshrc is or not overwritten in the future... I agree this is a bad solution, but at least for the time being my workaround...
lilyball commentedon Jul 27, 2020
I filed feedback for Apple (FB8181728). In the meantime,
nix-daemonwill need to learn how to modify the files appropriately on launch.abathur commentedon Oct 11, 2020
The zsh case seems to have been fixed (but not released yet) in the course of #3456. I haven't observed this same issue with bash shell files.Edit: this had its own problems and was reverted.
nixos-discourse commentedon Feb 3, 2021
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/here-are-the-etc-bashrc-amendments-performed-by-the-installer-on-macos/11360/1
stale commentedon Aug 2, 2021
I marked this as stale due to inactivity. → More info
elliot-u410 commentedon Aug 23, 2021
I'm still seeing this issue as of Nix 2.3.15 and Big Sur 11.5.2. The workaround is to re-add the following to
/etc/zshrc:abathur commentedon Aug 23, 2021
Edit: I see in matrix that #3608 caused its own problems documented in #4169, so I guess a release would actually be a step in the wrong direction atm... Striking through the parts that may not actually be much help...
FWIW this is roughly expected:
The fix for the ZSH case was merged in Use /etc/zshenv instead of /etc/zshrc for profile #3608, but there hasn't been a release from master since then (and it doesn't look like anyone's backported it). I'm not really in the loop, but at least per https://discourse.nixos.org/t/nix-release-schedule-and-roadmap/14204 there should be a release from master coming fairly soon?I would try manually migrating. I think you'd just need to create /etc/zshenv if it doesn't exist, move your source line there, and verify it works.Also: brownie points if you (or maybe any zsh user who hasn't taken 11.5.2 yet?) remember to report back here or in #3608 if this migration helps you dodge this problem.ggPeti commentedon Aug 23, 2021
can't we just patch zsh to use different rcfile paths? users can then set the patched zsh as their shell with nix-darwin
abathur commentedon Aug 23, 2021
@ggPeti I assume it's ideal if it still works without Nix-darwin, but tbh I have no clue how big the set of (Nix + zsh - nix-darwin) uses is.
#4169 seems to have a more robust discussion on ~zsh-specific fixes, and I'm trying to fish around for someone to add it to the 2.4 milestone; if I find someone, that might be a good place to pull on the thread...
63 remaining items
amckinlay commentedon Jan 12, 2025
Please deprecate nix on macOS until this issue is fixed.
ajmas commentedon Jan 17, 2025
You are free to not use it for your own needs, but given there is a workaround, I'd disagree with your suggestion. It would be more constructive to investigate and suggest ways we could resolve this to the benefit of the community as a whole. Additionally this only impacts upgrade time and not general runtime.
michaelfortunato commentedon Mar 13, 2025
Just got this issue upgrading to 15.3
stavalfi commentedon Mar 21, 2025
I'm having hard time making my r&d adopt nix on macOS due to this issue. They all stop use nix and go to homebrew installations after every macOS update.
Any help?
yanns commentedon Mar 21, 2025
Since I'm using
in
programs.zsh.initExtra(with homemanager), I've never had any issues anymore.alper commentedon Mar 21, 2025
I don't think there's that much to be done about that. The convenience differential is enormous even leaving out the breakage during upgrades.
vasigorc commentedon Apr 4, 2025
Thank you very much @elliot-u410 and @amckinlay I've already went through a re-install on Mac this year, and just hit
nix-shell:63: command not found: nix-shellagain after updating to Sequoia 15.4. With this hook everything works as expected!FranklinYu commentedon Apr 9, 2025
Until we have a solution that survives macOS updates, I suggest removing the part of updating
/etc/zshrc(and the Bash counterpart?) from the macOS installer. Reasons:/etc/zshrc) anyway. So this isn’t helping them, either.Instead of patching
/etc/zshrc, if we simply tell users to source that script from their shell config (like~/.zshrcor~/.bashrc), it is only a very little friction (if any at all) for new users. Advantage of this approach:Thoughts?
ajmas commentedon Apr 16, 2025
I recently moved to using Determinate for my Nix Shell, based on a friend's recommendation (he spends more time with system administration than I do).
I'll need to see how well this survives system updates, so I can't say at this point whether it is a "better" approach. I also haven't investigated the installation to see what it may do differently.
waszkiewiczj commentedon Apr 18, 2025
I can confirm that the solution works - my Macbook just got a system update and nix works after that. Although I've used
programs.zsh.initExtraFirstto make sure that this will always be on top of.zshrcfile.megmug commentedon Nov 4, 2025
I just upgraded from MacOS 26 to 26.1 and it broke the Nix install (official nixos.org installer).
I can confirm that just re-installing is a workaround, but the installer fails if Nix is already installed because it wants to back up
/etc/bashrcand/etc/bash.bashrc, and can't safely do so because it doesn't want to overwrite the old backup that the previous installer created.Moving these files around manually enables the installer to go through without further problems.
All in all, a workaround exists, but it's kind of a cumbersome solution, and it would be great if something could be done to make the experience more user-friendly.
Work around macOS occassionally eating Nix - NixOS/nix#3616
CielSoleil commentedon Mar 8, 2026
Happened to me today. Updating from 26.3 to 26.3.1 Official nix installer. Commands are gone, files are not. However, the bashrc file has the lines nix installer added, zshrc not.
Kiiyya commentedon Apr 19, 2026
Happened to me as well. I am not running nix-darwin, and only run home-manager. I see that for nix-darwin, this is fixed by DeterminateSystems/nix-installer#672.
Abdillah commentedon Apr 19, 2026
Nice info @Kiiyya, assuming no bug, then we can install Nix through https://github.com/NixOS/nix-installer/. That PR has been merged here too.
Just a note, it is different from current official script in the web.