Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nix-env and nix-build not found after installation (debian buster)

Tags:

nix

after the installation following the instructions with

curl https://nixos.org/nix/install | sh

and logout/login, nix-env and nix-build are not found. I had the problem with debian stretch and now with buster. What am I doing wrong?

like image 665
user855443 Avatar asked Jan 08 '19 07:01

user855443


People also ask

How do I reinstall nix?

To install Nix, run curl -L https://nixos.org/nix/install | sh as a non-root user and follow the instructions. Alternatively, you may prefer to download the installation script and verify its integrity using GPG signatures.

What is nix-ENV?

The command nix-env is used to manipulate Nix user environments. User environments are sets of software packages available to a user at some point in time. In other words, they are a synthesised view of the programs available in the Nix store.


1 Answers

The nix manual instructs to execute

source ~/.nix-profile/etc/profile.d/nix.sh

but the instructions printed after the execution say to do (I do not remember exactly)

./~/.nix-profile/etc/profile.d/nix.sh

and the same command is inserted into ~/.profile. The cause of the problem is the difference between . and source (see https://superuser.com/questions/46139/what-does-source-do). The script is setting up the $PATH variable in the environment and has the desired effect wtih source but no effect with . (which operates in its own shell and closes it at the end).

Cure: change the line in .profile (or better move it to .bashrc) to

if [ -e /home/xxx/.nix-profile/etc/profile.d/nix.sh ]; then source /home/xxx/.nix-profile/etc/profile.d/nix.sh; fi

(xxx is your user name),

like image 165
user855443 Avatar answered Oct 08 '22 07:10

user855443