NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.95k stars 1.53k forks source link

Issue with Installing Nix After MacOS Update (Nix stopped working) #7880

Open YashPotdar opened 1 year ago

YashPotdar commented 1 year ago

Platform

Additional information

After updating MacOS software to Ventura 13.2, I cannot run nix develop anymore. I can a nix: command not found error. I tried running this sh <(curl -L https://nixos.org/nix/install) --daemon but run into an error:

I made sure to follow these steps below:

  1. Back up (copy) /etc/bashrc and /etc/bashrc.backup-before-nix to another location, just in case.

  2. Ensure /etc/bashrc.backup-before-nix does not have anything Nix-related in it. If it does, something is probably quite wrong. Please open an issue or get in touch immediately.

Output

Output ```log mv /etc/bashrc.backup-before-nix /etc/bashrc override r--r--r-- root/wheel for /etc/bashrc? (y/n [n]) y mv: rename /etc/bashrc.backup-before-nix to /etc/bashrc: Permission denied ```

Priorities

Add :+1: to issues you find important.

abathur commented 1 year ago

For future reference: you don't have to reinstall after the update. The update is overwriting the shell hook, but you can just replace it. See #3616 for more.

At this point you'll have to follow the uninstall instructions before reinstalling it: https://nixos.org/manual/nix/stable/installation/installing-binary.html#macos

Nicceboy commented 1 year ago

For future reference: you don't have to reinstall after the update. The update is overwriting the shell hook, but you can just replace it. See #3616 for more.

This update broke something more. Whole daemon disappeared.

$ find /nix/var/nix/profiles/ | grep daemon
$ 

Also my ~/.nix-profile is empty directory. bin directories have disappeared and I can't find them.

abathur commented 1 year ago

@Nicceboy Not sure what update you're referring to, but I doubt a macOS update removed any of these.

I noticed some chatter about a regression related to profile paths in the 2.14.0 release of Nix (released yesterday). For reference, by ~chatter I mean:

I haven't had a chance to understand what happened there yet (and whether there's a quick workaround or when to expect a resolution), but I imagine it's what you're running into.

For now, I'd recommend following the uninstall directions I mentioned in my previous comment, and then reinstall with 2.13.3 (use https://releases.nixos.org/nix/nix-2.13.3/install instead of https://nixos.org/nix/install) to see if that fixes whatever you're running into.

Nicceboy commented 1 year ago

That might be a case.

However, I just updated to the most recent MacOS 13.2.1 and everything broke afterwards. Everything worked before that. Maybe I have updated Nix without noticing it and reboot changed something.

abathur commented 1 year ago

Maybe I have updated Nix without noticing it and reboot changed something.

Hmm. I doubt you did this without noticing. I was interpreting your quote of my comment as indicating that you'd tried to follow my instructions and were still having trouble.

As noted in my response to the OP, macOS updates are known to overwrite the shell hook in /etc/zshrc, which will remove Nix from your PATH.

I say that I doubt the macOS update removed any of the other bits because we occasionally get reports from people asserting that one macOS update or another overwrote/removed something else that Nix adds. Every time I see one of these, I go ask on Matrix to see if anyone else who has taken the same update observed the same problem, and I don't think I've been able to corroborate any except for /etc/zshrc. So, it's not impossible--but we'd need to know what's missing/changed, and we'd need enough reports from other users to be sure the update did it.

Your description might mean that your Nix Store volume has been deleted or isn't mounted, but I'm not really sure. diskutil list and diskutil info /nix could help clarify that. If you don't see the volume there, it might help to know if you have an /etc/synthetic.conf and /etc/fstab and what each contains. This could also be caused by a lot of other things, like encrypting your Nix Store after installing Nix or disabling the mounting service Nix installs.

Happy to work through collecting information about what may be going on if you aren't in a hurry--but it could take a bit to figure out, and the recommendation (a full uninstall and reinstall of 2.13.3) is focused on getting you up and running.

Nicceboy commented 1 year ago

Yeah, I know that macOS has very unlikely removed these files itself, is just wondered if it has touched Nix in some way which caused it to lose symlinks.

As update, I reinstalled the latest version and the problem persisted.

I reinstalled with the suggested version and it works as used to. The problem seems to be in the latest Nix version.

ekaeoq commented 1 year ago

Has anyone gotten around to fixing that issue? Just installed Sonoma and everything broke again, reinstalling the whole thing every time I update is so tedious

Nicceboy commented 1 year ago

Append following to the /etc/zshrc after updating.

# 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
mpstaton commented 1 week ago

point

The link you sent has uninstall instructions not install instructions.

abathur commented 1 week ago

point

The link you sent has uninstall instructions not install instructions.

(Assuming you meant the opposite--install instructions instead of uninstall instructions): The documentation's been reorganized in the 21 months since my comment. I pointed out that it broke the links at the time, but I guess it was changed in such a way that the anchors couldn't readily be remapped (correctly).

Here's my current version of the same saved reply:

You'll have to follow the uninstall instructions before reinstalling it: https://nixos.org/manual/nix/stable/installation/uninstall.html#macos

mpstaton commented 1 week ago

This is what happens when I follow the uninstall instructions:

image
abathur commented 1 week ago

You may need to kill that process or try rebooting.