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

Unable to install Nix 2.4 and 2.5.1 on Mac OS Monterey #5498

Closed
peterbecich opened this issue Nov 4, 2021 · 36 comments
Closed

Unable to install Nix 2.4 and 2.5.1 on Mac OS Monterey #5498

peterbecich opened this issue Nov 4, 2021 · 36 comments
Labels

Comments

@peterbecich
Copy link
Contributor

Describe the bug

The curl -L https://nixos.org/nix/install | sh script fails for me on Mac OS 12.0.1 Monterey.

...
/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9/
  unpack/nix-2.4-x86_64-darwin/install-multi-user: 
line 313: 72875 Killed: 9               sudo "$@"
...

Previously with Nix 2.3.* and Mac OS Big Sur, the script succeeded. I have upgraded to Monterey and Nix 2.4 at the same time, and do not know which upgrade is the issue, if either.

This issue appears similar to #5468 and #4779

Thank you

Steps To Reproduce

  1. curl -L https://nixos.org/nix/install | sh on Mac OS 12.0.1 Monterey

Expected behavior
Successful installation

nix-env --version output
No working Nix installation

Additional context

% curl -L https://nixos.org/nix/install | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  ...
downloading Nix 2.4 binary tarball for x86_64-darwin from 'https://releases.nixos.org/nix/nix-2.4/nix-2.4-x86_64-darwin.tar.xz' to '/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9'...
--2021-11-04 12:30:57--  https://releases.nixos.org/nix/nix-2.4/nix-2.4-x86_64-darwin.tar.xz
SSL_INIT
Resolving releases.nixos.org (releases.nixos.org)... 151.101.118.217
Connecting to releases.nixos.org (releases.nixos.org)|151.101.118.217|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35191732 (34M) [application/octet-stream]
Saving to: ‘/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9/nix-2.4-x86_64-darwin.tar.xz’

/var/folders/71/jl 100%[================>]  33.56M  7.17MB/s    in 5.3s

2021-11-04 12:31:02 (6.33 MB/s) - ‘/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9/nix-2.4-x86_64-darwin.tar.xz’ saved [35191732/35191732]

Switching to the Multi-user Installer
Welcome to the Multi-User Nix Installation

...

---- Found existing Nix volume -------------------------------------------------
  special:	disk1s7
     uuid:	44DC9C45-2A86-4778-B31D-AB75BA009F37
encrypted:	yes
Password:
Verifying the specific cryptographic user 44DC9C45-2A86-4778-B31D-AB75BA009F37 on APFS Volume disk1s7
Passphrase valid
Found a working decryption password in keychain :)


During install, I add 'nix' to /etc/synthetic.conf, which instructs
macOS to create an empty root directory for mounting the Nix volume.
Can I remove /etc/synthetic.conf?
No TTY, assuming you would say yes :)
During install, I add '/nix' to /etc/fstab so that macOS knows what
mount options to use for the Nix volume.
Can I remove /etc/fstab?
No TTY, assuming you would say yes :)

The installer adds a LaunchDaemon to mount your Nix volume: org.nixos.darwin-store
Can I remove it?
No TTY, assuming you would say yes :)

---- Nix config report ---------------------------------------------------------
        Temp Dir:	/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/tmp.QvYUcUFoMa
        Nix Root:	/nix
     Build Users:	32
  Build Group ID:	30000
Build Group Name:	nixbld

build users:
    Username:	UID
     _nixbld1:	301
     _nixbld2:	302
     _nixbld3:	303
     _nixbld4:	304
     _nixbld5:	305
     _nixbld6:	306
     _nixbld7:	307
     _nixbld8:	308
     _nixbld9:	309
     _nixbld10:	310
     _nixbld11:	311
     _nixbld12:	312
     _nixbld13:	313
     _nixbld14:	314
     _nixbld15:	315
     _nixbld16:	316
     _nixbld17:	317
     _nixbld18:	318
     _nixbld19:	319
     _nixbld20:	320
     _nixbld21:	321
     _nixbld22:	322
     _nixbld23:	323
     _nixbld24:	324
     _nixbld25:	325
     _nixbld26:	326
     _nixbld27:	327
     _nixbld28:	328
     _nixbld29:	329
     _nixbld30:	330
     _nixbld31:	331
     _nixbld32:	332

Ready to continue?
No TTY, assuming you would say yes :)

---- Preparing a Nix volume ----------------------------------------------------
    Nix traditionally stores its data in the root directory /nix, but
    macOS now (starting in 10.15 Catalina) has a read-only root directory.
    To support Nix, I will create a volume and configure macOS to mount it
    at /nix.

~~> Configuring /etc/synthetic.conf to make a mount-point at /nix

~~> Creating a Nix volume

~~> Configuring /etc/fstab to specify volume mount options

~~> Configuring LaunchDaemon to mount 'Nix Store'

~~> Setting up the build group nixbld
            Exists:	Yes

~~> Setting up the build user _nixbld1
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 1
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld2
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 2
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld3
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 3
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld4
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 4
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld5
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 5
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld6
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 6
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld7
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 7
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld8
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 8
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld9
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 9
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld10
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 10
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld11
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 11
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld12
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 12
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld13
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 13
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld14
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 14
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld15
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 15
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld16
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 16
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld17
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 17
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld18
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 18
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld19
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 19
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld20
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 20
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld21
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 21
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld22
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 22
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld23
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 23
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld24
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 24
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld25
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 25
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld26
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 26
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld27
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 27
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld28
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 28
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld29
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 29
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld30
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 30
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld31
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 31
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld32
            Exists:	Yes
            Hidden:	Yes
    Home Directory:	/var/empty
              Note:	Nix build user 32
   Logins Disabled:	Yes
  Member of nixbld:	Yes
    PrimaryGroupID:	30000

~~> Setting up the basic directory structure
chown: /nix/.Trashes: Operation not permitted
chown: /nix/.Trashes: Operation not permitted

~~> Installing Nix
      Alright! We have our first nix at /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4
/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9/unpack/nix-2.4-x86_64-darwin/install-multi-user: line 313: 72875 Killed: 9               sudo "$@"

---- oh no! --------------------------------------------------------------------
Jeeze, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.

:(

We'd love to help if you need it.

You can open an issue at https://github.com/nixos/nix/issues

Or feel free to contact the team:
 - Matrix: #nix:nixos.org
 - IRC: in #nixos on irc.libera.chat
 - twitter: @nixos_org
 - forum: https://discourse.nixos.org
@peterbecich peterbecich added the bug label Nov 4, 2021
@peterbecich
Copy link
Contributor Author

It was not solved by deleting /var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp

@abathur
Copy link
Member

abathur commented Nov 4, 2021

I'm not certain what this is, so I'm mostly just collecting info and connecting dots...

Did the install terminate on its own, or did it hang until you had to kill it? If you look under Crash Reports in Console.app, do you see an entry that matches up with the failure?

A "normal" segment here looks like:

~~> Installing Nix
      Alright! We have our first nix at /nix/store/...-nix-2.4
      Just finished getting the nix database ready.

The underlying command for the 2nd message is sudo /nix/store/...-nix-2.4/bin/nix-store --load-db

I don't think this is related to either linked issue:

There's some chance this is related to #3605, though I'm mostly just saying that because it is a known cause of intermittent failures. I don't specifically recall seeing any of those EOF reports mentioning nix-store --load-db, but I know there've been reports of it popping up rarely during installs.

@abathur
Copy link
Member

abathur commented Nov 4, 2021

If you have time to fiddle with this, reinstalling a few times may confirm or rule out the intermittent trouble in #3605

You can ping me in the macOS room on the NixOS Matrix if you want to run through it.

@javbit
Copy link

javbit commented Nov 5, 2021

I had a very similar failure to (re)install nix at around the same time as Peter yesterday (the issue was four minutes old when I checked GitHub). Tried it again this morning and it worked.

FWIW my attempt failed right after setting up the last build user.

Thanks!

@peterbecich
Copy link
Contributor Author

peterbecich commented Nov 11, 2021

Thank you

Did the install terminate on its own, or did it hang until you had to kill it? If you look under Crash Reports in Console.app, do you see an entry that matches up with the failure?

The install terminated on its own; these lines print instantaneously:

~~> Installing Nix
      Alright! We have our first nix at /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4
/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.I4RdTRj1/
  unpack/nix-2.4-x86_64-darwin/install-multi-user: line 313: 89548 Killed: 9               sudo "$@"

---- oh no! --------------------------------------------------------------------
Jeeze, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.

I don't see anything in Console.app but may have overlooked it.

The underlying command for the 2nd message is sudo /nix/store/...-nix-2.4/bin/nix-store --load-db

nix-store does not exist:

% sudo /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4/bin/nix
nix*                  nix-collect-garbage*  nix-env*              nix-prefetch-url*
nix-build*            nix-copy-closure*     nix-hash*             nix-shell*
nix-channel*          nix-daemon*           nix-instantiate*
% sudo /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4/bin/nix-store --help
sudo: /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4/bin/nix-store: command not found

and nix-store does not exist anywhere in /nix/store:

% pwd
/nix/store
% find . -name "nix-store"
no results

@abathur
Copy link
Member

abathur commented Nov 11, 2021

If you have time to fiddle with this, reinstalling a few times may confirm or rule out the intermittent trouble in #3605

You can ping me in the macOS room on the NixOS Matrix if you want to run through it.

Thanks for the additional detail. I think it's sounding more and more like a case of #3605.

I suspect reinstalling can fix it:

The installer backs up some system rc/profile files in /etc/ to /etc/<filename>.backup-before-nix before it adds Nix to them, and it'll refuse to run if it sees the backups. Once you replace the edited copies with the backups, though, you should be able to run the installer again. Confirm you see these files, first, but I think you'll just need to run:

sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc

@peterbecich
Copy link
Contributor Author

Those two files don't exist:

/etc % ls bashrc
bashrc                 bashrc_Apple_Terminal  bashrc~previous

/etc % ls zshrc
zshrc                 zshrc_Apple_Terminal

I have also deleted /nix/, and the APFS Nix Store using the Disk Utility.

@abathur
Copy link
Member

abathur commented Nov 11, 2021

Should be fine if they don't exist. If you have had Nix on the system before (installed multiple years ago--before the installer started making them back in 2.1) it might be worth making sure Nix isn't in either rc file, but otherwise I think you're ready to run the installer again.

@peterbecich
Copy link
Contributor Author

Yes, I had Nix on this system before, version 2.3.15 or 2.3.16. Maybe I should install the old version https://github.com/NixOS/nix/releases/tag/2.3.16 from source.

I've removed if [ -e ....nix-profile/etc/profile.d/nix.sh ]; then ....nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer from .zshenv, .zshrc, .bash_profile, etc. Nonetheless the same error occurs.

Thanks for your time

@abathur
Copy link
Member

abathur commented Nov 15, 2021

I guess that's a point against this being #3605, though I'm not quite convinced we should rule it out yet...

  1. When I was running into macOS: unexpected EOF reading a line #3605 while working on the installer last year, I noticed that builds got increasingly flaky as I ran more of them, and that rebooting helped. Can you try rebooting and giving the install process one more try?

  2. If that doesn't work, I agree it's worth giving an older installer a go (you can still upgrade the Nix in that install to 2.4 once it completes). At worst, it'll give us another data point.

    You shouldn't need to install it from source, though. You should be able to curl https://releases.nixos.org/nix/nix-2.3.16/install (or another specific version from http://releases.nixos.org/?prefix=nix/) instead of https://nixos.org/nix/install.

@peterbecich
Copy link
Contributor Author

peterbecich commented Nov 15, 2021

Thanks again

I was able to install Nix 2.3.16 successfully. It was necessary to delete /nix:

Without these steps, the Nix 2.3.15 failed due to /nix file permissions.

Then,

 curl -L -o install-nix https://releases.nixos.org/nix/nix-2.3.16/install
 sh install-nix --darwin-use-unencrypted-nix-store-volume

This is a single-user installation.

I don't think these steps would fix the Nix 2.4 installation curl -L https://nixos.org/nix/install | sh . I will upgrade from the 2.3.16 installation like you suggested, later. I really appreciate the help.

@supermarin
Copy link

Confirming the same issue here after upgrading from 2.3.10

@jonesnoaht
Copy link

I am having the same issue as well after migrating to a new Mac. I am stuck on sudo launchctl kickstart -k system/org.nixos.darwin-store, and the whole system crashes.

@peterbecich peterbecich reopened this Dec 6, 2021
@peterbecich
Copy link
Contributor Author

Would someone apply the "macos" label to this? https://github.com/NixOS/nix/issues?q=is%3Aissue+label%3Amacos+

@abathur
Copy link
Member

abathur commented Dec 6, 2021

I am having the same issue as well after migrating to a new Mac. I am stuck on sudo launchctl kickstart -k system/org.nixos.darwin-store, and the whole system crashes.

@jonesnoaht Can you clarify how you know you have the same issue, since no one in this thread has mentioned launchctl kickstart?

@jonesnoaht
Copy link

@abathur,

Sorry I have no idea what the heck I'm doing. It may be unrelated. I'll open a new issue.

@mgill25
Copy link

mgill25 commented Dec 19, 2021

I'm trying to install Nix on MacOS Big Sur, also facing trouble.

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo chmod -R ugo-w /nix/store/

to make the new store non-writable at /nix/store

      Alright! We have our first nix at /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/nix-store --load-db

to load data for the first time in to the Nix Database

/var/folders/m_/h5fyxf_51wq6tvbd59rgprj40000gn/T/nix-binary-tarball-unpack.XXXXXXXXXX.GJp2Zzwr/unpack/nix-2.5.1-x86_64-darwin/create-darwin-volume.sh: line 313: 70523 Killed: 9               sudo "$@"

---- oh no! --------------------------------------------------------------------
Jeeze, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.

:(

@abathur
Copy link
Member

abathur commented Dec 19, 2021

Anyone encountering this issue: it may help to have more reports to clarify whether this is indeed an intermittent/flaky failure. Please repeat this process a few (4?) times:

  1. Follow these clean-up steps:
    The installer backs up some system rc/profile files in /etc/ to /etc/<filename>.backup-before-nix before it adds Nix to them, and it'll refuse to run if it sees the backups. Once you replace the edited copies with the backups, though, you should be able to run the installer again. Confirm you see the backup files, first, but if so you'll just need to run:

    sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
    sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
    
  2. reboot

  3. try to install again (ideally, letting the installer re-make the volume--please note if you are telling it not to)

@peterbecich peterbecich changed the title Unable to install Nix 2.4 on Mac OS Monterey Unable to install Nix 2.4 and 2.5.1 on Mac OS Monterey Dec 20, 2021
@Eggham
Copy link

Eggham commented Dec 20, 2021

I reported Issue #5798.

I ran the above-mentioned process 4 times. Each time, I used sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon command. But it failed each time with the same error as mentioned in this issue and Issue #5798.

@abathur
Copy link
Member

abathur commented Dec 20, 2021

Just collecting and thinking out loud:

  • I'm not absolutely certain this and Installation nix on macOS fails #5798 are the same thing.
  • The line number is probably useless (it's just the _sudo wrapper I think).
  • I've been suspecting this is a case of macOS: unexpected EOF reading a line #3605, which is causing flaky builds (and has been seen during install, but IIRC manifests as an EOF error or a hang), but eggham's note above is another bit of evidence that this may be a durable failure.
  • If this failure is durable, it's presumably got something to do with system state, environment, or other local conditions?

For comparison, here are all of the failures mentioned in this thread so far:

From OP:

~~> Installing Nix
      Alright! We have our first nix at /nix/store/c3mvzszvyzakvcp9spnjvsb8m2bpjk7m-nix-2.4
/var/folders/71/jlb394z56hs8glkq6zvc2sq00000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.L1iVf5M9/unpack/nix-2.4-x86_64-darwin/install-multi-user: line 313: 72875 Killed: 9               sudo "$@"

From mgill25's comment:

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/nix-store --load-db

to load data for the first time in to the Nix Database

/var/folders/m_/h5fyxf_51wq6tvbd59rgprj40000gn/T/nix-binary-tarball-unpack.XXXXXXXXXX.GJp2Zzwr/unpack/nix-2.5.1-x86_64-darwin/create-darwin-volume.sh: line 313: 70523 Killed: 9               sudo "$@"

From log attached in #5798

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/nix-store --load-db

to load data for the first time in to the Nix Database

/var/folders/6j/zq8s4r2d7sb6bzs_l7_zk_tc0000gs/T/nix-binary-tarball-unpack.XXXXXXXXXX.fIKROhZo/unpack/nix-2.5.1-x86_64-darwin/create-darwin-volume.sh: line 313: 11395 Killed: 9               sudo "$@"

@abathur
Copy link
Member

abathur commented Dec 20, 2021

@Eggham If you haven't deleted the store volume, yet, can you see what ls -la /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/ says?

@Eggham
Copy link

Eggham commented Dec 21, 2021

@abathur There were a couple of things happened before I saw your above message, which are worth mentioning to avoid mislead you. After I reported this comment #5498 (comment). I managed to install Nix 2.3.16 successfully via sh <(curl -L https://releases.nixos.org/nix/nix-2.3.16/install) --darwin-use-unencrypted-nix-store-volume --daemon. Then I managed to upgraded it to Nix 2.4 successfully via sudo -i sh -c 'nix-channel --update && nix-env -iA nixpkgs.nix && launchctl remove org.nixos.nix-daemon && launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist'

When I read your above request #5498 (comment), I thought I would better to give you an accurate result based on the failure I encountered when I tried to install Nix 2.5.1. So I tried to re-install Nix 2.5.1 by following the process you mentioned in this comment #5498 (comment). What surprised me was that the error this time was very different. Please see the attached log.
new_nix_log.txt

Then I tried to delete all files within /nix without deleting /nix (it couldn't be deleted as it was readonly). After reboot I tried to install Nix 2.5.1. This time it produced the error very similar to that of #5798, as follows:

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/nix-store --load-db

to load data for the first time in to the Nix Database

/var/folders/6j/zq8s4r2d7sb6bzs_l7_zk_tc0000gs/T/nix-binary-tarball-unpack.XXXXXXXXXX.m2w3IATn/unpack/nix-2.5.1-x86_64-darwin/create-darwin-volume.sh: line 313:  4800 Killed: 9               sudo "$@"

Note the last line is slightly different from that of #5798.

Finally, when ran ls -la /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/ it produced the following result:

08f8bc787f66:~ xosler $ ls -la /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/
total 73392
dr-xr-xr-x  13 xosler  staff      416 Dec 21 09:22 .
dr-xr-xr-x   8 xosler  staff      256 Jan  1  1970 ..
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-build
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-channel
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-collect-garbage
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-copy-closure
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-daemon
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-env
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-hash
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-instantiate
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-prefetch-url
-r-xr-xr-x   1 xosler  staff  3413080 Jan  1  1970 nix-shell

Feel free to let me know if there are any more checks I can do. I will keep my environment unchanged for now in case you want me to do more checks or even experiments.

@cchalc
Copy link

cchalc commented Dec 21, 2021

So I recently did this and I had the exact same results as @Eggham. I made sure to uninstall following these instructions just for sanity and then proceeded to install with the exact same errors as @mgill25 link and @Eggham (#5798).

I followed the instructions above and was able to upgrade to 2.5.1

`christopher.chalcraft@C02CT8TEMD6M ~ % nix-shell -p nix-info --run "nix-info -m"

  • system: "x86_64-darwin"
  • host os: Darwin 19.6.0, macOS 10.15.7
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.5.1
  • channels(root): "nixpkgs-22.05pre339619.14f35764750"
  • nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs``

@Eggham
Copy link

Eggham commented Dec 21, 2021

@cchalc Thanks for sharing. Just wonder if you successfully installed (uninstalled first and then installed) Nix 2.5.1 by following your instructions? I would give it a try if it worked for you. Many thanks.

@Eggham
Copy link

Eggham commented Dec 21, 2021

I can confirm that above-mentioned approach does not solve the problem. Following it (uninstalling followed by installing) still gave me the same error:

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1/bin/nix-store --load-db

to load data for the first time in to the Nix Database

/var/folders/6j/zq8s4r2d7sb6bzs_l7_zk_tc0000gs/T/nix-binary-tarball-unpack.XXXXXXXXXX.W7NJjyao/unpack/nix-2.5.1-x86_64-darwin/create-darwin-volume.sh: line 313:  4402 Killed: 9               sudo "$@"

@abathur
Copy link
Member

abathur commented Dec 21, 2021

Feel free to let me know if there are any more checks I can do. I will keep my environment unchanged for now in case you want me to do more checks or even experiments.

@Eggham Thanks for checking on these. I don't have any other immediate thoughts. Just trying to collect information and then help the wheel squeak. @domenkozar

@cchalc
Copy link

cchalc commented Dec 21, 2021

@cchalc Thanks for sharing. Just wonder if you successfully installed (uninstalled first and then installed) Nix 2.5.1 by following your instructions? I would give it a try if it worked for you. Many thanks.

@Eggham I only used those for uninstalling to make sure everything was removed (It did miss some stuff in ~/.profile though. I then followed your instructions:

sh <(curl -L https://releases.nixos.org/nix/nix-2.3.16/install) --darwin-use-unencrypted-nix-store-volume --daemon

sudo -i sh -c 'nix-channel --update && nix-env -iA nixpkgs.nix && launchctl remove org.nixos.nix-daemon && launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist'

The only other thing I had to do was add the NIX_PATH to my ~/.profile
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels

@Eggham
Copy link

Eggham commented Dec 22, 2021

@cchalc Thanks for sharing the information. Just wonder whether or not you have successfully upgraded to Nix 2.5.1.

If so, did you upgrade from Nix 2.3.16 to Nix 2.4 first and then upgraded from Nix 2.4 to Nix 2.5.1, or upgraded from Nix 2.3.16 to Nix 2.5.1 in a single step?

Many thanks.

@mgill25
Copy link

mgill25 commented Dec 23, 2021

Update: 2.5.1 worked on my laptop without any issue. I did no cleanup and nothing special. The laptop wasn't even restarted since I posted the last comment. I only re-tried the curl command from the website (no additional flags).

~~> Setting up the basic directory structure
chown: /nix/.Trashes: Operation not permitted
chown: /nix/.Trashes: Operation not permitted

~~> Installing Nix
      Alright! We have our first nix at /nix/store/iq3ra93h9kxmnrw3zlxmqn8ng5w62dra-nix-2.5.1
      Just finished getting the nix database ready.

~~> Setting up shell profiles: /etc/bashrc /etc/profile.d/nix.sh /etc/zshrc /etc/bash.bashrc /etc/zsh/zshrc

# 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


# 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


# 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


~~> Setting up the default profile
installing 'nix-2.5.1'
building '/nix/store/4lnxyn7j0kpc4ir2qx39vd5jch28k494-user-environment.drv'...
installing 'nss-cacert-3.66'
building '/nix/store/6wndkfwgrdlc6igsnvwr22c07lbqvv2w-user-environment.drv'...
unpacking channels...

~~> Setting up the nix-daemon LaunchDaemon
Alright! We're done!
Try it! Open a new terminal, and type:

  $ nix-shell -p nix-info --run "nix-info -m"

Thank you for using this installer. If you have any feedback or need
help, don't hesitate:

You can open an issue at https://github.com/nixos/nix/issues

Or feel free to contact the team:
 - Matrix: #nix:nixos.org
 - IRC: in #nixos on irc.libera.chat
 - twitter: @nixos_org
 - forum: https://discourse.nixos.org

---- Reminders -----------------------------------------------------------------
[ 1 ]
Nix won't work in active shell sessions until you restart them.

❯ nix-channel --version
nix-channel (Nix) 2.5.1

❯ nix-shell --version
nix-shell (Nix) 2.5.1

@harriswarren
Copy link

Thanks @mgill25 I ran the install script with no flags and it worked! No uninstall or restart needed. @abathur This worked on a new Macbook Pro Max. :). I appreciate the support.

@peterbecich
Copy link
Contributor Author

I agree, works for me now. Thanks!

@s33dunda
Copy link

s33dunda commented Feb 2, 2022

OK I ran into this and got it to work. Thanks all for the contributions.

A note on my particular issue that may help others in the future:

I have a fresh macbook and had installed nix for the first time. Only to have issues with there not being a symlink to my users profile.

So, I uninstalled and tried re-installing, but produced the error leading me to this thread.
After a couple of failed attempts of uninstall/re-install I noticed that my PATH was light:

 echo $PATH
/usr/bin:/bin

After fixing this:

export PATH=/usr/bin:/bin:/usr/local/bin:/usr/sbin

The installation worked! good luck all

@DAddYE
Copy link

DAddYE commented Feb 2, 2022

OK I ran into this and got it to work. Thanks all for the contributions.

A note on my particular issue that may help others in the future:

I have a fresh macbook and had installed nix for the first time. Only to have issues with there not being a symlink to my users profile.

So, I uninstalled and tried re-installing, but produced the error leading me to this thread. After a couple of failed attempts of uninstall/re-install I noticed that my PATH was light:

 echo $PATH
/usr/bin:/bin

After fixing this:

export PATH=/usr/bin:/bin:/usr/local/bin:/usr/sbin

The installation worked! good luck all

Yup! Confirming that's was my issue too

@anilanar
Copy link

anilanar commented Feb 2, 2022

Sometimes it's not clear what exactly failed, is it possible to somehow have more verbosity? That was my biggest struggle, not being able to debug it. Maybe the error message can say which was the last thing that failed.

export PATH=/usr/bin:/bin:/usr/local/bin:/usr/sbin

This worked for me, thanks.

@abathur
Copy link
Member

abathur commented Feb 3, 2022

These recent comments probably have the same underlying cause that #5951 (hopefully) fixes... (there is a test installer in the linked PR, but it will only work on intel macs; a working M1 installer has been waiting on a long hydra queue...)

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/anyone-up-for-picking-at-some-nix-onboarding-improvements/13152/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests