NixOS / nix

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

error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted on Ubuntu 21.04 #5034

Open Marietto2008 opened 3 years ago

Marietto2008 commented 3 years ago

On ubuntu 21.04,I tried to install nix with this command :

ziomario@Z390-AORUS-PRO:~/Scaricati$ sudo curl -L https://nixos.org/nix/install | sh

[sudo] password for ziomario: 

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2619  100  2619    0     0   9628      0 --:--:-- --:--:-- --:--:--  9628
downloading Nix 2.3.14 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.3.14/nix-2.3.14-x86_64-linux.tar.xz' to '/tmp/nix-binary-tarball-unpack.ifymcYfetq'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25.7M  100 25.7M    0     0  9480k      0  0:00:02  0:00:02 --:--:-- 9480k
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...

but I've got this error :

error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted

I think that u already know that I can't install it as root.

enderger commented 3 years ago

As stated in the manual about single-user installations (which are done by default):

This will perform a single-user installation of Nix, meaning that /nix is owned by the invoking user. You should run this under your usual user account, not as root.

I'd remove /nix and try the install again, this time without using sudo.

stale[bot] commented 2 years ago

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

SeTSeR commented 2 years ago

I stumbled upon the same issue on Ubuntu 20.04 after installing Nix 2.8.1:

setser@machine:~$ nix doctor
error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted

The permissions for this directory are already correct:

setser@jakku:~$ ls -la /nix/var/nix/profiles/
total 16
drwxr-xr-x 3 root root 4096 May 16 20:09 .
drwxr-xr-x 8 root root 4096 May 16 20:09 ..
lrwxrwxrwx 1 root root   14 May 16 20:09 default -> default-1-link
lrwxrwxrwx 1 root root   60 May 16 20:09 default-1-link -> /nix/store/jablffvlwqn3c1mnry4hpq5pnm4cz8mk-user-environment
drwxr-xr-x 3 root root 4096 May 16 20:09 per-user

Removing nix and reinstalling does not help.

SeTSeR commented 2 years ago

Removing nix as described in manual and reinstalling helped, seems like something remained from previous nix installation.

prateekrajgautam commented 5 months ago

I think it needs windows administrator access,

  1. Launch powershell as admin Right click on start then select power shell(admin)
  2. Launch wsl, type wsl in admin powershell
  3. Then use nix-shell
cognivore commented 3 months ago

Removing nix as described in manual and reinstalling helped, seems like something remained from previous nix installation.

Which manual page do you mean?

cole-h commented 3 months ago

Probably this one: https://nix.dev/manual/nix/stable/installation/uninstall.html#uninstalling-nix