Name collision from multiple installs

Hi all,

I recently tried to install Nix package manager on WSL2 and first came across this link. I installed nix using
sudo install -d -m755 -o $(id -u) -g $(id -g) /nix $ curl -L | sh.
However, after rebooting the terminal I still could not get Nix to work and I found what I probably should have used from the start. I ran
sh <(curl -L --daemon.
I then ran nix-env --query --available --attr-path to see if I had anything and got the follwing warning:
warning: name collision in input Nix expressions, skipping '/home/ukiva/.nix-defexpr/channels_root/nixpkgs' suggestion: remove 'nixpkgs' from either the root channels or the user channels.
I’m now having collisions when trying to install packages, is there any way I can fix this?


Yes, this should be quite simple. Run these two commands to show all root channels and all your user channels:

sudo nix-channel --list
nix-channel --list

The error message is probably caused by nixpkgs being present in both of them.

You can run

sudo nix-channel --remove nixpkgs

to remove it from the root channels. I would recommend this so you can run nix-channel --update to update all your channels at once without sudo.


Thanks for the reply. When I try and run

sudo nix-channel --list

I get

sudo: nix-channel: command not found

I’m not sure how it could not be installed on root. I get a similar message when trying
sudo nix-channel --remove nixpkgs. Any ideas?

Ah right, it’s possible that the default profile is still empty. No worries, though, you can fix that easily:

sudo $(which nix-env) -iA nixpkgs.nix

If that doesn’t help, just replace nix-channel in the calls above with $(which nix-channel). This will be replaced by your shell with the absolute path of the nix-channel executable, so it doesn’t matter if it’s in the PATH or not.

Thanks for the help!