安装后未找到 nix-env 和 nix-build (debian buster)

use*_*443 4 nix

按照说明安装后

curl https://nixos.org/nix/install | sh
Run Code Online (Sandbox Code Playgroud)

并且未找到注销/登录、nix-env 和 nix-build。我遇到了 debian stretch 的问题,现在使用了 buster。我究竟做错了什么?

use*_*443 5

nix手册指示执行

source ~/.nix-profile/etc/profile.d/nix.sh
Run Code Online (Sandbox Code Playgroud)

但执行后打印的指令说要做(我不记得了)

./~/.nix-profile/etc/profile.d/nix.sh
Run Code Online (Sandbox Code Playgroud)

并将相同的命令插入到~/.profile. 这个问题的原因是之间的差异.source(见https://superuser.com/questions/46139/what-does-source-do)。该脚本正在环境中设置 $PATH 变量,并具有所需的效果,source但没有效果.(在其自己的 shell 中运行并在最后关闭它)。

解决方法:将.profile(或更好地将其移至.bashrc)中的行更改为

if [ -e /home/xxx/.nix-profile/etc/profile.d/nix.sh ]; then source /home/xxx/.nix-profile/etc/profile.d/nix.sh; fi
Run Code Online (Sandbox Code Playgroud)

xxx是您的用户名),

  • 然而,`./~/...` 和 `./~/...` 之间有很大的区别。〜/...`; 前者只是一个以当前工作目录开头的路径(可能无效,因为当前工作目录中可能没有名为“~”的目录)。 (2认同)

Rob*_*oby 0

您需要添加此推荐脚本