Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-shell does not work when bashCompletion is enabled #7611

Closed
vu3rdd opened this issue Apr 28, 2015 · 14 comments
Closed

nix-shell does not work when bashCompletion is enabled #7611

vu3rdd opened this issue Apr 28, 2015 · 14 comments
Labels
0.kind: question Requests for a specific question to be answered 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Comments

@vu3rdd
Copy link
Contributor

vu3rdd commented Apr 28, 2015

I am using nix-shell and the quick start example in the manual (step #6
listed here: https://nixos.org/nix/manual/) does not seem to work for
me:

[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.

@peti
Copy link
Member

peti commented Apr 28, 2015

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 peti added the 0.kind: question Requests for a specific question to be answered label Apr 28, 2015
@vu3rdd
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

@peti I don't have a ~/.bashrc file on my home directory. If it can be of any help, here is my configuration.nix.

@vu3rdd
Copy link
Contributor Author

vu3rdd commented 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 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.

@domenkozar
Copy link
Member

It may be related to another package that provides the bash completion. What do you have in environment.systemPackages?

@domenkozar domenkozar added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Apr 28, 2015
@vu3rdd
Copy link
Contributor Author

vu3rdd commented 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
Copy link
Member

peti commented Apr 28, 2015

@vu3rdd, can you please paste the complete output that you get when running nix-shell -p hello with bash completion enabled?

@vu3rdd
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

@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.

evaluating file ‘/nix/store/b68f8byrg1ibybixhjl8s3c6vvk0y6ld-nix-1.8/share/nix/corepkgs/derivation.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/default.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/top-level/all-packages.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/adapters.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/trivial-builders.nix’
evaluating file ‘/home/ram/.nixpkgs/config.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/default.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/trivial.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/lists.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/strings.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/strings-with-deps.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/attrsets.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/sources.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/options.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/types.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/meta.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/debug.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/misc.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/systems.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/customisation.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/linux/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/generic/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/compression/gzip/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/servers/x11/xorg/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/licenses.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/platforms.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/linux/bootstrap/x86_64.nix’
|   evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/linux/bootstrap/i686.nix’
evaluating file ‘/nix/store/b68f8byrg1ibybixhjl8s3c6vvk0y6ld-nix-1.8/share/nix/corepkgs/fetchurl.nix’
evaluating file ‘/nix/store/b68f8byrg1ibybixhjl8s3c6vvk0y6ld-nix-1.8/share/nix/corepkgs/config.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/misc/patchelf/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/cc-wrapper/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/misc/binutils/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/zlib/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/fetchurl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/build-support/fetchurl/mirrors.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/compression/xz/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/os-specific/linux/paxctl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/glibc/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/glibc/common.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/os-specific/linux/kernel-headers/3.12.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/interpreters/perl/5.20/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/top-level/platforms.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/cloog/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/isl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/libelf/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/misc/coreutils/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/acl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/misc/texinfo/5.2.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/system/which/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/gettext/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/gmp/5.1.x.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/misc/gnum4/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/mpfr/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/libmpc/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/compression/bzip2/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/shells/bash/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/shells/bash/bash-4.3-patches.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/parsing/bison/3.x.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/attr/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/text/diffutils/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/misc/findutils/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/text/gawk/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/libsigsegv/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/tools/build-managers/gnumake/4.1/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/text/gnused/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/archivers/gnutar/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/text/gnugrep/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/pcre/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/text/gnupatch/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/applications/editors/ed/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/stdenv/common-path.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/networking/curl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/openssl/default.nix’
evaluating file ‘/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/development/libraries/libssh2/default.nix’

@peti
Copy link
Member

peti commented Apr 28, 2015

@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.

@vu3rdd
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

Here it is:

[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:~]$ 

@peti
Copy link
Member

peti commented 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
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

Yes, I reported that in the original report too. Yes, I use bash.

@vu3rdd
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

@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:

  1. adding bashCompletion package in the system Packages.
  2. 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
Copy link
Member

peti commented Apr 28, 2015

Don't put bashCompletioninto systemPackages. Having programs.bash.enableCompletion = true is sufficient to enable it.

@vu3rdd
Copy link
Contributor Author

vu3rdd commented Apr 28, 2015

Sure. Closing the bug. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Projects
None yet
Development

No branches or pull requests

3 participants