4 ms·
Yeah this is a documentation footgun for some¹ users, and unfortunately is more likely to hit new users and dabblers than the experienced or dedicated Nix users
by pxc 3y ago
Yeah this is a documentation footgun for some¹ users, and unfortunately is more likely to hit new users and dabblers than the experienced or dedicated Nix users who can just step over it. It sucks.
It's true that the information in that section² of the manual is correct, and also true that those snippets are not instructions, so the manual is not instructing anyone to do a thing that will break their computer... but if some Nix profile is the only thing putting Nix on your PATH and you switch away from that profile, you will naturally no longer have Nix on your PATH, and the next Nix command you try to run will fail. The docs should warn you about that in this section, and the application should also warn you on any actions that might leave your PATH Nixless like this.
There's another problem here, I think only hinted at in that GitHub issue, in that if you switch to an empty or nonexistent profile and start a new shell, the `/bin` path in your profile won't be added to your shell's PATH on shell startup because it doesn't exist. And then when you do install something to that profile, it won't be on your PATH until you start a new shell.
The issue you filed should be reopened as a documentation bug, and a new issue should be created about warning users on operations that might render their PATHs Nixless.
If anyone does hit this or something similar: you can just run nix-env or any other Nix binaries directly from the Nix store, or from one of the other still-existing profile links under /nix/var/nix/profiles, e.g. /nix/var/nix/profiles/per-user/$USER/bin/nix-env, to switch your profile back.
--
1: Namely, Nix users whose Nix binaries are provided in a per-user profile and are running Nix as the relevant users. NixOS users, Nix-Darwin users, System Manager users, users of regular old multi-user Nix installs, and users who install Nix itself via their distro's package manager aren't affected.
2: https://nixos.org/manual/nix/stable/package-management/profiles.html?highlight=switch#profiles https://nixos.org/manual/nix/stable/package-management/profi...