Skip to content

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

Closed

Description

@vu3rdd

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.

Activity

  1. peti commented on Apr 28, 2015

    @peti
    Member

    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.

  2. added
    0.kind: question
    on Apr 28, 2015
  3. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

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

  4. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

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

  5. domenkozar commented on Apr 28, 2015

    @domenkozar
    Member

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

  6. added
    6.topic: nixos
    on Apr 28, 2015
  7. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

    @domenkozar @peti It looks like it works just fine if I remove the bashCompletion package. What does the bashCompletion package do?

  8. peti commented on Apr 28, 2015

    @peti
    Member

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

  9. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

    @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’
    
  10. peti commented on Apr 28, 2015

    @peti
    Member

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

  11. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

    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:~]$ 
    
  12. peti commented on Apr 28, 2015

    @peti
    Member

    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?

  13. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

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

  14. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

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

  15. peti commented on Apr 28, 2015

    @peti
    Member

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

  16. vu3rdd commented on Apr 28, 2015

    @vu3rdd
    ContributorAuthor

    Sure. Closing the bug. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: question6.topic: nixos

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions