Hi, I have found a strange behaviour of nix-shell when I try to make it run some simple Shell commands inside a spawned nix-shell
. It works as expected on one machine, but not on another. It seems like the argument I passed for --run
somehow got interpreted as Nix instead of Shell script. Here are the console output for running the command on the two machines: (I’m using -p python3
simply because I don’t need to create a default.nix
to call the Shell command, and Python 3 is a pretty stable package).
Machine A (work as expected):
harry@machine-a ~> nix-shell --version
nix-shell (Nix) 2.3.10
harry@machine-a ~> nix-shell -p python3 --run "echo Hello" --pure
Hello
Machine B (not working):
harry@machine-b ~> nix-shell --version
nix-shell (Nix) 2.3.10
harry@machine-b ~> nix-shell -p python3 --run "echo Hello" --pure exited nix-shell
error: undefined variable 'Hello' at (string):1:104
(use '--show-trace' to show detailed location information)
Both are using fish
3.1.2 too. But since I am still a very early learner of Nix and NixOS, I am worried it might be me not fully understanding how nix-shell
works yet. I would be grateful to see some ideas from anyone. Thanks!