NixOS / nix

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

New nix installation fails on macOS #2690

Open brandondrew opened 5 years ago

brandondrew commented 5 years ago

I freshly installed Nix on macOS Mojave 10.14.3 (18D42) and had the same experience in both iTerm and Terminal:

Last login: Tue Feb 19 19:13:40 on ttys078
You have mail.
Haddock
πŸ’»  curl https://nixos.org/nix/install | sh

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2476  100  2476    0     0   3803      0 --:--:-- --:--:-- --:--:--  3803
downloading Nix 2.2.1 binary tarball for x86_64-darwin from 'https://nixos.org/releases/nix/nix-2.2.1/nix-2.2.1-x86_64-darwin.tar.bz2' to '/var/folders/83/2wr1s45x1c5gygsgyn33p1tc0000gn/T/nix-binary-tarball-unpack.XXXXXXXXXX.R7088Sdb'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.9M  100 19.9M    0     0   530k      0  0:00:38  0:00:38 --:--:--  350k
Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation
performing a single-user installation of Nix...
copying Nix to /nix/store...................................
initialising Nix database...
replacing old 'nix-2.2.1'
installing 'nix-2.2.1'
building '/nix/store/nsczlwdkf3dbcyc7xqp5ca4ccqrpp2vc-user-environment.drv'...
created 22 symlinks in user environment
unpacking channels...

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /Users/brandon/.nix-profile/etc/profile.d/nix.sh

in your shell.
πŸ’»  . /Users/brandon/.nix-profile/etc/profile.d/nix.sh
/Users/brandon/.nix-profile/etc/profile.d/nix.sh:stat:14: %u: no such file or directory
Nix: WARNING: bad ownership on /nix/var/nix/profiles/per-user/brandon, should be 501
/Users/brandon/.nix-profile/etc/profile.d/nix.sh:stat:39: %u: no such file or directory
Nix: WARNING: bad ownership on /nix/var/nix/gcroots/per-user/brandon, should be 501

Regarding the warnings, I verified that I'm user 501:

πŸ’»  id -u                                                                                               61486  02-19 20:04 EST  ~  Haddock
501

The portions of the file with the errors are:

14     if [ "$(stat --printf '%u' "$NIX_USER_PROFILE_DIR")" != "$(id -u)" ]; then
15         echo "Nix: WARNING: bad ownership on "$NIX_USER_PROFILE_DIR", should be $(id -u)" >&2
16     fi

and

39         if [ "$(stat --printf '%u' "$__user_gcroots")" != "$(id -u)" ]; then
40             echo "Nix: WARNING: bad ownership on $__user_gcroots, should be $(id -u)" >&2
41         fi

The verification that the installation failed was that I could not install anything:

πŸ’»  nix-env -i elvish                                                                                   61490  02-19 20:07 EST  ~  Haddock
zsh: command not found: nix-env
brandondrew commented 5 years ago

P.S. I looked through several macOS issues with related titles, but this did not appear to be like the others I saw.

matthewbauer commented 5 years ago

It looks like you are getting the stat from /usr/bin/ and not the stat from coreutils. Can you make sure that this line is setting PATH correctly: https://github.com/NixOS/nix/blob/master/scripts/nix-profile.sh.in#L3

You should be able to run this successfully:

PATH=@coreutils@ stat --printf '%u' .

where @coreutils@ is the actual path to coreutils in nix.sh.

abathur commented 3 years ago

I think this may be obsolete.

I don't see any references to stat --printf, NIX_USER_PROFILE_DIR or __user_gcroots in the Nix repo.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info