Repository navigation
Closed
Labels
0.kind: bugSomething is broken
Description
Basic info
To make sure that we are on the same page:
- Kernel: (run
uname -a) - System: (NixOS:
nixos-version, Ubuntu/Fedora:lsb_release -a, ...) - Nix version: (run
nix-env --version) - Nixpkgs version: (run
nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)
[anders@gurney:~]
$ uname -a
Linux gurney 4.5.0 #1-NixOS SMP Mon Mar 14 04:28:54 UTC 2016 x86_64 GNU/Linux
[anders@gurney:~]
$ nixos-version
16.09.git.9549257 (Flounder)
[anders@gurney:~]
$ nix-env --version
nix-env (Nix) 1.11.2
[anders@gurney:~]
$ nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
"16.09.git.9549257"
Describe your issue here
This seems to have already been encountered as #7611, but not fully investigated.
enabling bash completion breaks nix-shell.
Expected result
with bash completion turned off, I see this, which is correct
[anders@gurney:~]
$ nix-shell -p wget --command 'which wget'
/nix/store/ksjdhd0mrv9lxg00li06b3zpdc5z4nb2-wget-1.17.1/bin/wget
[anders@gurney:~]
$ nix-shell -p wget
[nix-shell:~]$ exit
exit
Actual result
after setting programs.bash.enableCompletion = true; and doing a nixos-rebuild switch, I see this. It looks like the environment is wiped - the nix shell doesn't even exit correctly ($IN_NIX_SHELL) and the prompt is not set to the hardcoded [nix-shell:~]$
[anders@gurney:~]
$ echo $IN_NIX_SHELL
[anders@gurney:~]
$ nix-shell -p wget --command 'which wget'
[anders@gurney:~]
$ echo $IN_NIX_SHELL
1
[anders@gurney:~]
$ exit
More Expected Result
this works correctly in each of the following three cases
- bash completion turned of in configuration.nix
[anders@gurney:~]
$ echo $IN_NIX_SHELL
[anders@gurney:~]
$ nix-shell -p wget --command 'which wget'
/nix/store/ksjdhd0mrv9lxg00li06b3zpdc5z4nb2-wget-1.17.1/bin/wget
[anders@gurney:~]
$ echo $IN_NIX_SHELL
- bash completion on, but I use --pure
[anders@gurney:~]
$ echo $IN_NIX_SHELL
[anders@gurney:~]
$ nix-shell --pure -p which -p wget --command 'which wget'
/nix/store/ksjdhd0mrv9lxg00li06b3zpdc5z4nb2-wget-1.17.1/bin/wget
[anders@gurney:~]
$ echo $IN_NIX_SHELL
- bash completion on, but setting PS1="" before entering the nix-shell
[anders@gurney:~]
$ export PS1=""
echo $IN_NIX_SHELL
nix-shell -p wget --command 'which wget'
/nix/store/ksjdhd0mrv9lxg00li06b3zpdc5z4nb2-wget-1.17.1/bin/wget
echo $IN_NIX_SHELL
Notes
I also have programs.bash.promptInit set, as
promptInit = ''
PS1='\[\033[1;32m\][\u@\h:\w]\n\$\[\033[0m\] '
'';
I've taken a look at the generated /etc/bashrc, and I suspect that it has to do with this extremely fragile looking logic
# We are not always an interactive shell.
if [ -n "$PS1" ]; then
...
Reacted by Ole Jørgen Brønner and Peter Hoeg
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken
Activity
anderspapitto commentedon Mar 24, 2016
updated the report - I had linked to the wrong original bug report
Profpatsch commentedon Jun 23, 2018
triage: does this bug still occur?
elmarx commentedon Nov 11, 2018
Can't reproduce, so it seems it's fixed.
Since 80b6513 bashCompletion is even on by default, so if this bug would still be present, it would probably affect a lot more users now.
So, IMO this issue should be closed.