11

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?

user855443
  • 2,596
  • 3
  • 25
  • 37

3 Answers3

9

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 this superuser question). 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),

sb813322
  • 129
  • 9
user855443
  • 2,596
  • 3
  • 25
  • 37
  • There is no difference between `source` and `.`; they are synonyms for the same command. – chepner Jan 24 '19 at 21:05
  • 2
    There is, however, a big difference between `./~/...` and `. ~/...`; the former is just a path (likely invalid, as you probably don't have a directory named `~` in the current working directory) starting with the current working directory. – chepner Jan 24 '19 at 21:18
  • I assume that my memory was not perfect and i left out the space between `.` and `~`. The discussion I quoted above is clearly stating the subtle difference between `source` and `.` - they synonymous on the same command but have different effects on teh environment. Read the discussion! – user855443 Jan 26 '19 at 09:03
  • The discussion you quoted talks about the difference between a *path* that starts with `.` (resulting in *executing* the script) versus sourcing it (whether with `.` or `source`). – chepner Jan 26 '19 at 14:44
2

For me only setting $PATH like this worked (in .profile)

export PATH="$PATH:/nix/var/nix/profiles/default/bin"
sb813322
  • 129
  • 9
E.Fulassofu
  • 51
  • 1
  • 2
  • 7
0

You need to add this recommended script.

sb813322
  • 129
  • 9
Roby
  • 2,011
  • 4
  • 28
  • 55