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

Failed to enable unit: File /etc/systemd/system/nix-daemon.socket already exists and is a symlink to /dev/null. #8772

Open ekg opened 1 year ago

ekg commented 1 year ago

Platform

Additional information

I was trying to do an uninstall/reinstall of nix. I failed several times due to difficulty cleaning up all the state.

I'm getting Failed to enable unit: File /etc/systemd/system/nix-daemon.socket already exists and is a symlink to /dev/null.

Output

Output ```log ---- sudo execution ------------------------------------------------------------ I am executing: $ sudo systemctl enable /nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.socket to set up the nix-daemon socket service Failed to enable unit: File /etc/systemd/system/nix-daemon.socket already exists and is a symlink to /dev/null. ---- oh no! -------------------------------------------------------------------- Oh no, 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. ```

Priorities

Add :+1: to issues you find important.

abathur commented 1 year ago

It's unclear--have you followed the multi-user Linux uninstall instructions https://nixos.org/manual/nix/stable/installation/uninstall.html#linux?

ekg commented 1 year ago

I did follow exactly these multi-user Linux uninstall instructions.

abathur commented 1 year ago

I'm not terribly familiar with systemd, but I've been trying to fish around and got this comment on matrix:

Not sure about sockets specifically and that error, but for just systemd units it would be unmask (as masking is making it a symlink to /dev/null).

If they do something like systemctl status nix-daemon.socket it should say something like 'Loaded: masked (/dev/null; bad)'

Can you see if that's what you get?

ekg commented 1 year ago

I get this:

○ nix-daemon.socket
     Loaded: masked (Reason: Unit nix-daemon.socket is masked.)
     Active: inactive (dead)

... systemd[1]: nix-daemon.socket: Socket service nix-daemon.service already active, refusing.
... systemd[1]: Failed to listen on Nix Daemon Socket.
abathur commented 1 year ago

If I'm following along correctly, this means the nix daemon was ~disabled by running systemctl mask at some point, so you'll need to use systemctl unmask to get the socket (and probably the unit) out of this state (and then maybe use systemctl disable per the uninstall directions) before trying to reinstall.

ekg commented 1 year ago

I solved my issues by using the nix-installer.

https://github.com/DeterminateSystems/nix-installer