Cant install nix!

Use your favourite editor like Emacs, vim, vscode, whatever, edit the mentioned line, save, rerun.

Mostly to connect dots, this is the subject of `install-multi-user.sh` asks user to "edit this script" when it's invoked by the `curl | sh` script · Issue #4915 · NixOS/nix · GitHub.

My first comment in that thread includes some notes on how you can approach changing it.

1 Like

Use your favourite editor like Emacs, vim, vscode, whatever, edit the mentioned line, save, rerun.

Here is the problem. This error message is entirely useless because you simply cannot find the file to edit. The https://nixos.org/nix/install script is not the one you want to edit - It downloads the actual installer, extracts it into a random temporary directory, and deletes it when an error occurs. In other words, when you see this error message the files simply don’t exist anymore!

1 Like

OH, sorry about my snippy answer then. I assumed that https://nixos.org/nix/install was the script to edit, and not some second or third level helper script…

Alternatively and for Debian specifically, you might want to try nix-bin from the Debian repositories if this script doesn’t work. I haven’t used it and it’s not the most recent version of Nix, but it will probably bootstrap everything correctly and you can progress from there.

1 Like

I have a similar issue : when trying the multi-user installation I get the error message

It seems the build group nixbld already exists, but
with the UID 998. This script can’t really handle
that right now, so I’m going to give up.

You can fix this by editing this script and changing the
NIX_BUILD_GROUP_ID variable near the top to from 30000
to 998 and re-run.

I am completely unable to understand the solution suggested in Github issue #4915. Is there a simpler / more brutal approach I could take ?

It looks like these were made configurable via environment in installer: allow overriding nix user GID and UIDs by bjornfor · Pull Request #4345 · NixOS/nix · GitHub, so you should just be able to export NIX_BUILD_GROUP_ID=998 before you invoke the installer.

@abathur Thank you for the answer. Sadly this does not work, I just get the same error message but with “999” instead of “998”, and export NIX_BUILD_GROUP_ID=999 then installing leads to a mistake again. Also, anytime I open a terminal I get the bash: /home/user/.nix-profile/etc/profile.d/nix.sh: No such file or directory error message. At that point I am tempted to just re-install my Ubuntu distribution, is there any way to get around that?

1 Like

At this point I don’t think your ubuntu install is to blame, but the previous failed installations of nix.

I would try to uninstall nix first, see Uninstalling Nix - Nix Reference Manual

To install nix afterwards, try to use the determinate installer. It is not official, but takes great care to not leave your system in a broken state of it fails in some way and might replace the official installer at some point in the future.

2 Likes

Thanks. I deleted the multi-user installation of Nix as indicated, but the determinate installer still stops with error message ``nix is already a valid command, so it is installed. Before that I have a warning warning: the group 'nixbld' specified in 'build-users-group' does not exist nix-env (Nix) 2.6.0.
Do you have any idea as to where I should look for deleting Nix before reinstalling it?

Presumably it’s still installed. Might have missed a step, or maybe a step errored and didn’t run right? Might also have a Nix installed by some other package manager?

What does type -a nix or which -a nix say?

Indeed, it says /usr/bin/nix and /bin/nix. I am trying to install the Lean proof assistant (https://leanprover.github.io/), but this also fails (and uninstalling it thanks to elan does not make the Nix installation succeed)

Unclear if “indeed” means you know there’s a Nix installed by some other PM?

In any case, those aren’t normal paths for the Nix binary, so those are either symlinks or you may have some kind of package manager install. You can try readlink /usr/bin/nix to check for the symlink. If you’ve got a Nix installed by some other PM, you’ll need to follow their instructions to clean it up.

That seems like you followed the advice that was given 9 months ago:

In addition to @abathur’s suggestion, can you check if you can uninstall nix-bin using debian’s package manager?

2 Likes

Thank you for the suggestion. I have uninstalled nix-bin, remove the elan package manager, which I think was using nix, and I’m pretty sure I don’t have installed anything else that uses nix.
Trying to install Nix the the determinate installer, I now get another error message:

Error: 
   0: Planner error
   1: Error executing action
   2: Action `configure_init_service` errored
   3: `/etc/systemd/system/nix-daemon.socket` already exists, consider removing it with `rm /etc/systemd/system/nix-daemon.socket`

Location:
   src/cli/subcommand/install.rs:159

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

Consider reporting this error using this URL: https://github.com/DeterminateSystems/nix-installer/issues/new?title=%3Cautogenerated-issue%3E&body=%23%23+Error%0A%60%60%60%0AError%3A+%0A+++0%3A+Planner+error%0A+++1%3A+Error+executing+action%0A+++2%3A+Action+%60configure_init_service%60+errored%0A+++3%3A+%60%2Fetc%2Fsystemd%2Fsystem%2Fnix-daemon.socket%60+already+exists%2C+consider+removing+it+with+%60rm+%2Fetc%2Fsystemd%2Fsystem%2Fnix-daemon.socket%60%0A%60%60%60%0A%0A%23%23+Metadata%0A%7Ckey%7Cvalue%7C%0A%7C--%7C--%7C%0A%7C**version**%7C0.9.1%7C%0A%7C**os**%7Clinux%7C%0A%7C**arch**%7Cx86_64%7C%0A

Should I open an issue on the determinate installer repository? Is there any Nix command which could check wether Nix is installed through other PM?

1 Like

I’d just try its suggestion (rm /etc/systemd/system/nix-daemon.socket). It sounds like either the pm install or the other multi-user install you mentioned wasn’t completely cleaned up.

You may also try rebooting, sockets sometimes only get cleaned up on reboot. I’m not sure why, but I’ve seen it happen.

But the suggestion from the installer should work as well (you might need sudo)

1 Like

Thanks for your suggestions. Indeed, after rm /etc/systemd/system/nix-daemon.socket (twice, no idea why), the command nix --version gives nix (Nix) 2.13.3. However, whenever I open a terminal I still have the error message at the top: bash: /home/user/.nix-profile/etc/profile.d/nix.sh: No such file or directory. Would you know why/where to look?

Nice, ok! You didn’t say it, but after the rm calls you did run the determinate installer successfully, correct?

About your error, this is likely from a source line in some bashrc file, probably a leftover artifact from the old installation. There’s a few locations where this file could be sourced:

  • /etc/profile
  • /etc/bash.bashrc
  • ~/.bashrc
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

Please check for all those files if they exist, and if so, whether they contain a line like this:

[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ] && source "$HOME/.nix-profile/etc/profile.d/nix.sh"

If so, delete it, and save the file.

Once you’ve done this for all of the files I listed, you can try running a new instance of bash again, and the error should be gone.

1 Like

Yes, the file ~/.bashrc was the culprit, thank you! There is no error message now.