You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nix-shell does not work when bashCompletion is enabled #7611
0.kind: questionRequests for a specific question to be answered6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
[ram@nixos:~] nix-shell -p hello
these paths will be fetched (0.04 MiB ...
*** Downloading ....
[ram@nixos:~]$ hello
The program `hello' is currently not installed ...
...
[ram@nixos:~]$ exit
[ram@nixos:~]$
Note that the prompt string didn't change when we entered the nix-shell.
If I do:
[ram@nixos:~]$ nix-shell -p hello --pure
[nix-shell:~]$ hello
Hello, world!
[nix-shell:~]$
Now, I figured that I have bashCompletion enabled in the /etc/nixos/configuration.nix. programs.bash.enableCompletion = true;
If I comment this line out and do nixos-rebuild switch, then nix-shell works as expected (both with and without the -pure flag).
I believe this is a bug. nix-shell -v does not seem to show anything interesting w.r.t this particular behaviour, so not including the output of that here.
I cannot reproduce this error. On my system, everything works as expected:
[simons@latitude:~]$ nix-shell -p hello
these paths will be fetched (0.00 MiB download, 0.19 MiB unpacked):
/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10
fetching path ‘/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’...
*** Trying to download/patch ‘/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’
*** Step 1/1: downloading ‘http://hydra.nixos.org/nar/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’ to ‘/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 46674 0 46674 0 0 58861 0 --:--:-- --:--:-- --:--:-- 65553
[nix-shell:~]$ type -p hello
/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10/bin/hello
[nix-shell:~]$ hello
Hello, world!
Personally, I believe it's far more likely that the cause for this issue is @vu3rdd's ~/.bashrc setup than a bug in nix-shell. nix-shell doesn't care whether bash completion is enabled or not; it just sets up a bunch of environment variables and executes a shell. What this shell does, however, is to some extend dependent on what the user configured their shell to do at start-up.
@peti another data: Without the comment on programs.bash.enableCompletion = true;, I did a fresh install of nixos from the ISO with the same configuration file (I had to comment out the kernel 4.0 because I was installing stable). Now, this won't boot into xmonad. Now, I commented the enableCompletion line and did a nixos-rebuild switch and it boots into xmonad just fine.
Is there a way to see any logs of what is happening in the system or why it failed to boot into xmonad even though the configuration explicitly said so? Perhaps that may reveal something on the failure.
@peti This is the output with bashCompletion in the systemPackages and programs.bash.enableCompletion = true; and nix-shell -v -p hello.
I also tried the log with bashCompletion removed from systemPackages and did a diff of the log file generated, but it is exactly the same.
@vu3rdd, this is not what I need. Please configure your system with bash completion enabled, run nixos-rebuild switch, and then run nix-env -p hello and paste the output from that last command only.
[ram@nixos:~]$ nix-shell -p hello
these paths will be fetched (0.05 MiB download, 0.21 MiB unpacked):
/nix/store/jg990hzan73yksf8gghmri5iszdrr8mg-stdenv
/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10
fetching path ‘/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’...
*** Downloading ‘https://cache.nixos.org/nar/166y7i5irx8sgm1whwjbq32xj8cn86yxbw2qfgwr1ldi915wili6.nar.xz’ to ‘/nix/store/qbjjyf1s5lhc59vir6rj7j1zxzq4i6w4-hello-2.10’...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 40308 100 40308 0 0 19735 0 0:00:02 0:00:02 --:--:-- 25608
fetching path ‘/nix/store/jg990hzan73yksf8gghmri5iszdrr8mg-stdenv’...
*** Downloading ‘https://cache.nixos.org/nar/0arra09bx5p4kr5yc2n9vs9m1awkpjwk12idl108zafq7fad4vp9.nar.xz’ to ‘/nix/store/jg990hzan73yksf8gghmri5iszdrr8mg-stdenv’...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7356 100 7356 0 0 10359 0 --:--:-- --:--:-- --:--:-- 10375
[ram@nixos:~]$
OK. Now, the shell's prompt should say [nix-shell:~]$, but it does not. Clearly, you are not inside of a proper nix-shell environment at that point. What shell do you use? bash?
@peti are you able to reproduce it by including bashCompletion in the systemPackages and doing a nixos-rebuild switch and enabling the bash completion?
Just to summarize, there are 2 things in play:
adding bashCompletion package in the system Packages.
programs.bash.enableCompletion = true;
Leaving both on, does not enter into the nix-shell environment.
Leaving item 1 on and item 2 off, gets me into the shell.
Leaving item 1 off and item 2 on gets me into the shell.
Leaving item 1 off and item 2 off also gets me into the shell.
0.kind: questionRequests for a specific question to be answered6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Activity
peti commentedon Apr 28, 2015
I cannot reproduce this error. On my system, everything works as expected:
Personally, I believe it's far more likely that the cause for this issue is @vu3rdd's
~/.bashrcsetup than a bug innix-shell.nix-shelldoesn't care whether bash completion is enabled or not; it just sets up a bunch of environment variables and executes a shell. What this shell does, however, is to some extend dependent on what the user configured their shell to do at start-up.vu3rdd commentedon Apr 28, 2015
@peti I don't have a
~/.bashrcfile on my home directory. If it can be of any help, here is my configuration.nix.vu3rdd commentedon Apr 28, 2015
@peti another data: Without the comment on
programs.bash.enableCompletion = true;, I did a fresh install of nixos from the ISO with the same configuration file (I had to comment out the kernel 4.0 because I was installing stable). Now, this won't boot into xmonad. Now, I commented the enableCompletion line and did anixos-rebuild switchand it boots into xmonad just fine.Is there a way to see any logs of what is happening in the system or why it failed to boot into xmonad even though the configuration explicitly said so? Perhaps that may reveal something on the failure.
domenkozar commentedon Apr 28, 2015
It may be related to another package that provides the bash completion. What do you have in
environment.systemPackages?vu3rdd commentedon Apr 28, 2015
@domenkozar @peti It looks like it works just fine if I remove the bashCompletion package. What does the bashCompletion package do?
peti commentedon Apr 28, 2015
@vu3rdd, can you please paste the complete output that you get when running
nix-shell -p hellowith bash completion enabled?vu3rdd commentedon Apr 28, 2015
@peti This is the output with
bashCompletionin the systemPackages andprograms.bash.enableCompletion = true;andnix-shell -v -p hello.I also tried the log with
bashCompletionremoved from systemPackages and did a diff of the log file generated, but it is exactly the same.peti commentedon Apr 28, 2015
@vu3rdd, this is not what I need. Please configure your system with bash completion enabled, run
nixos-rebuild switch, and then runnix-env -p helloand paste the output from that last command only.vu3rdd commentedon Apr 28, 2015
Here it is:
peti commentedon Apr 28, 2015
OK. Now, the shell's prompt should say
[nix-shell:~]$, but it does not. Clearly, you are not inside of a proper nix-shell environment at that point. What shell do you use?bash?vu3rdd commentedon Apr 28, 2015
Yes, I reported that in the original report too. Yes, I use bash.
vu3rdd commentedon Apr 28, 2015
@peti are you able to reproduce it by including bashCompletion in the systemPackages and doing a
nixos-rebuild switchand enabling the bash completion?Just to summarize, there are 2 things in play:
bashCompletionpackage in the system Packages.programs.bash.enableCompletion = true;Leaving both on, does not enter into the nix-shell environment.
Leaving item 1 on and item 2 off, gets me into the shell.
Leaving item 1 off and item 2 on gets me into the shell.
Leaving item 1 off and item 2 off also gets me into the shell.
peti commentedon Apr 28, 2015
Don't put
bashCompletionintosystemPackages. Havingprograms.bash.enableCompletion = trueis sufficient to enable it.vu3rdd commentedon Apr 28, 2015
Sure. Closing the bug. Thanks.