Skip to content
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

macOS Ventura, /nix is empty after reboot following clean installation #212

Closed
zmitchell opened this issue Jan 27, 2023 · 17 comments · Fixed by #215
Closed

macOS Ventura, /nix is empty after reboot following clean installation #212

zmitchell opened this issue Jan 27, 2023 · 17 comments · Fixed by #215
Assignees
Labels
bug Something isn't working MacOS Darwin/MacOS

Comments

@zmitchell
Copy link

zmitchell commented Jan 27, 2023

What I did

I ran the command to install:

$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

I ran the installation process (I don't remember the exact steps, I didn't realize there was a failure at this point yet). I sourced whatever script it mentioned and was able to run the nix command. That was yesterday.

Symptoms

Today, likely after opening a new terminal, I'm no longer able to run the nix command. I looked in my .zshrc and there's nothing sourcing anything having to do with nix. Further investigation shows that there's nothing in /etc/nix besides nix.conf.

I downloaded the installer directly to see if I could use it to repair my installation:

$ curl -sL -o nix-installer https://install.determinate.systems/nix/nix-installer-aarch64-darwin

then I ran nix-installer plan and immediately ran into this error:

$ ./nix-installer plan
Error:
   0: Planner error
   1: Error executing action
   2: Path exists `/Library/LaunchDaemons/org.nixos.darwin-store.plist`

Location:
   /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/convert/mod.rs:726

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

This tells me that the installation at least put some files in the right place.

Ok, what if I run the uninstall command?

$ ./nix-installer uninstall
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Error:
   0: Reading receipt
   1: No such file or directory (os error 2)

Location:
   src/cli/subcommand/uninstall.rs:126

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Sure enough, there's no /nix/receipt.json (makes sense, I said earlier that /etc/nix only contains receipt.json). I thought this was supposed to be created during the installation process?

Questions

  • How do I repair the installation?
  • How do I verify that the installation is complete?
  • What went wrong?
@zmitchell
Copy link
Author

I dug through my shell history to find out which file I sourced during the installation procedure:

$ . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh

What's interesting is that /nix/var no longer exists for whatever reason. I certainly never typed in a command to delete the directory, so maybe it was removed by the daemon script or it was only there temporarily?

@zmitchell
Copy link
Author

I just went through the uninstallation procedure I found here: https://iohk.zendesk.com/hc/en-us/articles/4415830650265-Uninstall-nix-on-MacOS

Then I tried to install again. What I noticed is that if I tried to run the installer without root, it proceeded and ran into an error, only mentioning that it needed root along the way:

❯ ./nix-installer install darwin-multi
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
Nix install plan (v0.1.0)

Planner: darwin-multi

Planner settings:

* nix_build_group_name: "nixbld"
* volume_encrypt: false
* volume_label: "Nix Store"
* root_disk: null
* case_sensitive: false
* nix_build_user_id_base: 300
* force: false
* extra_conf: []
* nix_package_url: "https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-aarch64-darwin.tar.xz"
* nix_build_group_id: 3000
* nix_build_user_count: 32
* channels: ["nixpkgs=https://nixos.org/channels/nixpkgs-unstable"]
* modify_profile: true
* nix_build_user_prefix: "_nixbld"

The following actions will be taken:

* Create an APFS volume `Nix Store` for Nix on `disk3`
* Fetch `https://releases.nixos.org/nix/nix-2.12.0/nix-2.12.0-aarch64-darwin.tar.xz` to `/nix/temp-install-dir`
* Create build users (UID 300-332) and group (GID 3000)
* Create a directory tree in `/nix`
* Move the downloaded Nix into `/nix`
* Setup the default Nix profile
* Configure Nix daemon related settings with systemd
* Place the Nix configuration in `/etc/nix/nix.conf`
* Place channel configuration at `/Users/zmitchell/.nix-channels`
* Configure the shell profiles
* Kickstart the launchctl unit `system/org.nixos.nix-daemon`


Proceed? ([Y]es/[n]o/[e]xplain):

I cleaned up any files that this left behind after hitting the error, deleted the /nix volume, rebooted, and tried the installer again with root:

$ sudo ./nix-installer install darwin-multi

This installation succeeded. Afterwards I was able to run nix commands, there was a receipt.json in /nix. All seemed well. Then I rebooted just to see if it would stick. No dice, we're back to where I started where everything in /nix is missing.

So at least I can reproduce the issue now?

@zmitchell
Copy link
Author

More developments! I uninstalled, then ran the official installer and the contents of /nix survived the reboot. Next step is to try running nix-installer again without sudo to double check that sudo wasn't causing some permissions issue with mounting the contents of /nix.

@zmitchell
Copy link
Author

Uninstalled and then ran nix-installer without sudo and I was prompted to enter my password, which I did. That's what we expect, so that's good. I took a look at the fstab with sudo vifs and noticed that the official installer references the volume by UUID whereas nix-installer references the volume by NAME. Not sure if that's an issue, but I've written down the UUID as seen in Disk Utility so if /nix is empty I can potentially try referencing via UUID instead of name to see if that will mount it properly.

@zmitchell
Copy link
Author

That was it! When I rebooted /nix was again empty. I edited the fstab with sudo vifs and replaced NAME="Nix Store" with UUID=<my UUID>, rebooted, and everything seems to be working.

@zmitchell zmitchell changed the title macOS M1 silent installation failure macOS Ventura, /nix is empty after reboot following clean installation Jan 28, 2023
@elgertam
Copy link

I also have experienced this issue. Haven't tried @zmitchell's proposed fix yet, though I'll probably reset my system and do so.

@woodwardjd
Copy link

woodwardjd commented Jan 28, 2023

During our brand new M2 (max, MacBook Pro 16) configurations this weekend we decided to give this a try instead of the official install. Ran into the same symptom (/nix empty on reboot). The fstab edit to use the UUID instead of the name worked for us.

Thanks @zmitchell for the thorough report AND reporting the workaround! And thanks to the team behind this tool for the great docs and simple tool. It makes onboarding folks into a dev ecosystem that uses nix a ton easier.

@elgertam
Copy link

Can confirm that using vifs to update the entry in /etc/fstab to UUID=<disk UUID> rather than NAME="Nix Store" solved my problem. Nix is now running & loading properly after reboot.

@Hoverbear
Copy link
Contributor

Hoverbear commented Jan 29, 2023

@zmitchell Thanks for reporting this! It seems you found a bug and found the fix!

I'll work on reflecting this fix in the installer and cut a new version this week!

I'm sorry about the issues! I'm not a Mac user myself and while we did test rebooting on the remote ephemeral Macs I suspect they are a bit different than a "real" user machine.

@zmitchell
Copy link
Author

No worries, it was fun to debug it :) I'm learning Nix and can volunteer to test things on macOS if you need a real machine to test on in the future.

@Hoverbear
Copy link
Contributor

Out of curiousity, does your system have any other volumes on it called Nix Store?

@woodwardjd
Copy link

woodwardjd commented Jan 30, 2023

@Hoverbear mine may or may not have (I don't think it did). My partner's definitely did not.

edit: it definitely didn't. My install failed when I did have that existing volume. I disconnected it before getting the successful install, and I haven't reattached it since (I only had it originally connected to run Migration Assistant from its contents).

@zmitchell
Copy link
Author

I didn't. This was my first time installing Nix and while I was debugging I deleted the Nix Store volume during each uninstall.

@Hoverbear
Copy link
Contributor

Okay! Thanks! We had a report from someone else where they'd previously installed Nix and experienced this, I just wanted to see if it was isolated to that particular case.

@Hoverbear
Copy link
Contributor

Hoverbear commented Jan 30, 2023

Okay, #215 should apply this workaround! I've tested it a few times on our ephemeral Macs and they seem quite content with themselves.

If you'd be willing to be a guinea pig for me:

Because you changed the /etc/fstab line it may be safe to revert to starting with NAME="Nix Store" before doing this! I don't think we're that clever quite yet.

/nix/nix-installer uninstall

Then:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/215 | sh -s -- install

I hope this works. :)

@Hoverbear Hoverbear self-assigned this Jan 30, 2023
@Hoverbear Hoverbear added the bug Something isn't working label Jan 30, 2023
@woodwardjd
Copy link

Close! fstab shows /nix as the mount point. After Install+Reboot the volume gets mounted at /Volumes/Nix Store anyway. I removed the quotes in fstab's UUID="xyz-123-...", resulting in UUID=xyz-123..., and after a reboot it automounts at /nix and it's back to smooth sailing.

@Hoverbear
Copy link
Contributor

Ah heck! Ok! Thanks! We'll make that change and a release should happen in the next day or two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MacOS Darwin/MacOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants