nix-shell shebang fails silently #1037

Closed
opened 2025-11-17 19:28:01 +00:00 by rbt · 2 comments
Owner

Describe the bug

Using nix-shell as a shebang interpreter doesn't seem to work.

Steps To Reproduce

With test.py:

#! /usr/bin/env nix-shell
#! nix-shell -i python -p python3
print("hello")
$ nix --version
nix (Lix, like Nix) 2.93.3
System type: x86_64-linux
...
$ ./test.py
$ echo $status
1

Expected behavior

$ nix --version
warning: unknown setting 'repl-overlays'
nix (Nix) 2.31.2
$ ./test.py
warning: unknown setting 'repl-overlays'
hello

nix --version output

$ nix --version
nix (Lix, like Nix) 2.93.3
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/wiggles/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/wiggles/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/wiggles/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/wiggles/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/x58imd6kxmj49r5hiavc85l7qhzk3m1q-lix-2.93.3/share
## Describe the bug Using [`nix-shell` as a shebang interpreter](https://nix.dev/manual/nix/2.25/command-ref/nix-shell.html?highlight=shebang#use-as-a--interpreter) doesn't seem to work. ## Steps To Reproduce With `test.py`: ```python #! /usr/bin/env nix-shell #! nix-shell -i python -p python3 print("hello") ``` ``` $ nix --version nix (Lix, like Nix) 2.93.3 System type: x86_64-linux ... $ ./test.py $ echo $status 1 ``` ## Expected behavior ``` $ nix --version warning: unknown setting 'repl-overlays' nix (Nix) 2.31.2 $ ./test.py warning: unknown setting 'repl-overlays' hello ``` ## `nix --version` output ``` $ nix --version nix (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/wiggles/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/wiggles/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/wiggles/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/wiggles/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/x58imd6kxmj49r5hiavc85l7qhzk3m1q-lix-2.93.3/share ```
Owner

dupe:
#1020
#940

dupe: https://git.lix.systems/lix-project/lix/issues/1020 https://git.lix.systems/lix-project/lix/issues/940
raito closed this issue 2025-11-17 19:30:37 +00:00
Author
Owner

Fix for this is to sudo rm /tmp/env-vars btw

Fix for this is to `sudo rm /tmp/env-vars` btw
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1037
No description provided.