Skip to content

nix-shell completely broken #976

Closed
Closed

Description

@matthiasbeyer

nix-shell is broken, as reported in this mailinglist thread and the follow-up messages.

  • System: 16.09pre85931.125ffff (Flounder)
  • Nix version: nix-env (Nix) 1.11.2
  • Nixpkgs version: "16.09pre85931.125ffff"

Activity

  1. matthiasbeyer commented on Jul 18, 2016

    @matthiasbeyer
    ContributorAuthor

    Hm. I'm not sure. I just tried nix 1.10 and the issue persists. I tried with --run and it worked. I guess it is some issue with the/my setup, but I cannot track it down.

    On the ML there were suggestions that this might because of some PATH variable modifications, but there are none in my bashrc file.

  2. edolstra commented on Jul 18, 2016

    @edolstra
    Member

    Works for me:

    $ nix-shell -p calcurse
    
    [nix-shell:~]$ type -p calcurse
    /nix/store/08lhvzm941h6w4f2srd5yrrf6z64z3rp-calcurse-4.0.0/bin/calcurse
    
  3. matthiasbeyer commented on Jul 18, 2016

    @matthiasbeyer
    ContributorAuthor
    $ nix-shell -p calcurse
    $ # yes, I'm getting my normal prompt here, not the nix-shell prompt, but $SHLVL increased
    $ # as posted in the mailinglist thread, my $PATH isn't modified within this new shell instance
    $ type -p calcurse
    $ #no output

    So it must be with my setup.

  4. matthiasbeyer commented on Jul 18, 2016

    @matthiasbeyer
    ContributorAuthor

    Issue persists after reboot.

  5. zimbatm commented on Jul 18, 2016

    @zimbatm
    Member

    I'm having the same issue on my system but it works when using --pure. Removing the .bashrc and .profile in my home doesn't fix the problem. Creating a new user (with wheel access) and executing there does work. It might be something to do with the existing environment.

  6. matthiasbeyer commented on Jul 18, 2016

    @matthiasbeyer
    ContributorAuthor

    @zimbatm Yes, I also guess it is the environment. I do not have a .profile or .bashrc file in my $HOME, though. Just the /etc/bashrc where no modification to $PATH are made besides:

    if [[ -d $HOME/archive/bin ]]
    then
      export PATH=$PATH:$HOME/archive/bin
    fi

    edit: And that snippet is in my /etc/bashrc for ... years now... so I don't think that's the issue, actually.

  7. samuelrivas commented on Jul 19, 2016

    @samuelrivas

    @zimbatm Maybe a stupid question, but have you tried comparing the environment variables in the case it works and int he case it doesn't?

  8. matthiasbeyer commented on Jul 19, 2016

    @matthiasbeyer
    ContributorAuthor

    @samuelrivas For me they are equal (by shasum).

  9. domenkozar commented on Jul 21, 2016

    @domenkozar
    Member

    @matthiasbeyer you'll have to figure out yourself why this happens, it's hard to guess from the description.

  10. matthiasbeyer commented on Jul 21, 2016

    @matthiasbeyer
    ContributorAuthor

    @domenkozar ... hmmh. nix-shell in the store is a symlink to nix-build. If I call nix-build -p calcurse --run bash it gives me

    these derivations will be built:
      /nix/store/zxqnrqp4jwml0lnyj2wixb4dy4q7lhw0-shell.drv
    building path(s) ‘/nix/store/hpnr8zfa6qr1rpi6g8mz9wlpbyf3vpgp-shell’
    builder for ‘/nix/store/zxqnrqp4jwml0lnyj2wixb4dy4q7lhw0-shell.drv’ failed to produce output path ‘/nix/store/hpnr8zfa6qr1rpi6g8mz9wlpbyf3vpgp-shell’
    error: build of ‘/nix/store/zxqnrqp4jwml0lnyj2wixb4dy4q7lhw0-shell.drv’ failed
    
  11. fkz commented on Jul 23, 2016

    @fkz
    Contributor

    I have the same issue, already for quite some time, worked around it with nix-shell ... -p bashInteractive --run bash until now. interestingly, as mentioned here, --pure also works. Otherwise, no clue why this happens

  12. joachifm commented on Jul 26, 2016

    @joachifm

    I cannot reproduce this either; I fail to see how this issue can be resolved without further information, nor do I think it's fair to say that nix-shell is "completely broken" in its current state ...

  13. matthiasbeyer commented on Jul 26, 2016

    @matthiasbeyer
    ContributorAuthor

    nor do I think it's fair to say that nix-shell is "completely broken" in its current state ...

    Well, for me it is. I don't know either how to reproduce, but as you can read, others have.

  14. peti commented on Jul 26, 2016

    @peti
    Member

    nix-shell works just fine for me on NixOS 16.03, on unstable, and on a openSUSE Tumbleweed host system running Nix from master. It strikes me as highly unlikely that nix-shell is "broken", really. It seems far more likely that your shell's setup scripts are doing something that breaks the interactive environment. A simple way to verify or contradict that hypothesis is to run

    nix-shell -p haskell.compiler.ghc7103 --command "bash --noprofile"
    

    or

    nix-shell -p haskell.compiler.ghc7103 --command "bash --norc"
    

    and then run ghc --version to check whether the compiler is in scope like it should be. If it is, then apparently not sourcing your start-up scripts makes a difference.

  15. matthiasbeyer commented on Jul 27, 2016

    @matthiasbeyer
    ContributorAuthor

    With nix-shell -p haskell.compiler.ghc7103 --command "bash --noprofile" I get no prompt until I press CTRL-C. Same for nix-shell -p haskell.compiler.ghc7103 --command "bash --norc"

    Anyways, the bash I get does not contain ghc.

    Okay, so it seems it is my fault somehow... but I cannot see how and why. Should I share my bashrc file?

  16. 8 remaining items

  17. fkz commented on Jul 28, 2016

    @fkz
    Contributor

    your patch has to be changed to include the -x after the --rcfile because appearantly, bash only accepts short options after long options.

    Anyway, with this adjustment, I'm getting https://gist.github.com/fkz/fd2a33b224aff92436d29f6762e465b5 for nix-shell -p python.

    Seems to be lots of stuff for bash_completion, maybe I should turn that off somehow and test again...

  18. olejorgenb commented on Aug 12, 2016

    @olejorgenb
    Contributor
  19. domenkozar commented on Aug 12, 2016

    @domenkozar
    Member

    @matthiasbeyer would you test turning bash completion off and confirm?

  20. matthiasbeyer commented on Aug 12, 2016

    @matthiasbeyer
    ContributorAuthor

    I just disabled bash completion in my configuration.nix and then:

    nixos-rebuild build
    ./target/sw/bin/xterm
    
    # in the new xterm:
    nix-shell -p calcurse

    I got the same results in the new xterm, ... prompt didn't change and calcurse was downloaded (curl output) but not in scope.

  21. hedning commented on Aug 14, 2016

    @hedning

    Having had the issue, disabling bash completion worked. Bash completion for c++ was apparently the first culprit triggering the bug.

    After some debugging with strace etc. this seems to be the problem:

    nix-build generates a temporary rc file for bash. The first thing this rc file does is to remove itself, meaning it can only be run once. Since BASH_ENV is also set to this file, all non-interactive calls to bash will source this file. This means that any such calls, before the main shell has a chance to source the rc file, will break nix-shell. (link to relevant code)

    All autocompletion files are sourced from /etc/bashrc which is run before the rc file given by --rcfile. So there's a big risk of this happening. (edit: .bashrc -> /etc/bashrc)

    In my case the completion file for c++ triggered the bug by calling c++ --version ..., a bash script which will source BASH_ENV. Using strace you can see that all later calls to the rc file fails.

    Removing $ENV{BASH_ENV} = $rcfile; fixes the issue (--run still works). The alternative would be to handle the removal of the temporary file in a different manner.

  22. added 2 commits that reference this issue on Aug 16, 2016
    16fbd5d
    5de6c80
  23. deepfire commented on Aug 23, 2016

    @deepfire

    Another userspace bug diagnosed by the transcendental powers of strace !

  24. fkz commented on Aug 24, 2016

    @fkz
    Contributor

    #1034 appears to work for me, too, and finally fixes this annoying bug, thanks a lot @hedning !

  25. added a commit that references this issue on Sep 8, 2016
    8bddc3d
  26. matthiasbeyer commented on Nov 21, 2016

    @matthiasbeyer
    ContributorAuthor

    Somehow, this issue still exists for me. Can someone tell me step-by-step how to debug this?

  27. olejorgenb commented on Nov 21, 2016

    @olejorgenb
    Contributor

    @matthiasbeyer Are you sure your nix have the fix? I don't think nix have had an release since the fix: The commit is dated 8. sept. while the last release is dated 6. sept. To make sure you actually have the fix open nix-build and search for $ENV{BASH_ENV} = $rcfile; If it's present you don't have the fix.

  28. shlevy commented on Nov 21, 2016

    @shlevy
    Member

    @edolstra Can we get a new 1.11 release?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions