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
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.
$ 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
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.
@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 ]]
thenexport 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.
@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
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
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 ...
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
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.
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?
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.
Reacted by Fabian Schmitthenner, Kosyrev Serge and Robin Stumm
Reacted by Fabian Schmitthenner
Reacted by Fabian Schmitthenner and Anthony Cowley
@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.
Activity
matthiasbeyer commentedon Jul 18, 2016
Hm. I'm not sure. I just tried nix 1.10 and the issue persists. I tried with
--runand 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
PATHvariable modifications, but there are none in my bashrc file.edolstra commentedon Jul 18, 2016
Works for me:
matthiasbeyer commentedon Jul 18, 2016
So it must be with my setup.
matthiasbeyer commentedon Jul 18, 2016
Issue persists after reboot.
zimbatm commentedon Jul 18, 2016
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.matthiasbeyer commentedon Jul 18, 2016
@zimbatm Yes, I also guess it is the environment. I do not have a
.profileor.bashrcfile in my$HOME, though. Just the/etc/bashrcwhere no modification to$PATHare made besides:edit: And that snippet is in my
/etc/bashrcfor ... years now... so I don't think that's the issue, actually.samuelrivas commentedon Jul 19, 2016
@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?
matthiasbeyer commentedon Jul 19, 2016
@samuelrivas For me they are equal (by
shasum).domenkozar commentedon Jul 21, 2016
@matthiasbeyer you'll have to figure out yourself why this happens, it's hard to guess from the description.
matthiasbeyer commentedon Jul 21, 2016
@domenkozar ... hmmh.
nix-shellin the store is a symlink tonix-build. If I callnix-build -p calcurse --run bashit gives mefkz commentedon Jul 23, 2016
I have the same issue, already for quite some time, worked around it with
nix-shell ... -p bashInteractive --run bashuntil now. interestingly, as mentioned here,--purealso works. Otherwise, no clue why this happensjoachifm commentedon Jul 26, 2016
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 ...
matthiasbeyer commentedon Jul 26, 2016
Well, for me it is. I don't know either how to reproduce, but as you can read, others have.
peti commentedon Jul 26, 2016
nix-shell works just fine for me on NixOS 16.03, on
unstable, and on a openSUSE Tumbleweed host system running Nix frommaster. It strikes me as highly unlikely thatnix-shellis "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 runor
and then run
ghc --versionto 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.matthiasbeyer commentedon Jul 27, 2016
With
nix-shell -p haskell.compiler.ghc7103 --command "bash --noprofile"I get no prompt until I pressCTRL-C. Same fornix-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?
8 remaining items
fkz commentedon Jul 28, 2016
your patch has to be changed to include the
-xafter the--rcfilebecause 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...
olejorgenb commentedon Aug 12, 2016
Probably related/same issue? programs.bash.enableCompletion breaks nix-shell
domenkozar commentedon Aug 12, 2016
@matthiasbeyer would you test turning bash completion off and confirm?
matthiasbeyer commentedon Aug 12, 2016
I just disabled bash completion in my
configuration.nixand then:nixos-rebuild build ./target/sw/bin/xterm # in the new xterm: nix-shell -p calcurseI got the same results in the new xterm, ... prompt didn't change and
calcursewas downloaded (curloutput) but not in scope.hedning commentedon Aug 14, 2016
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-buildgenerates a temporary rc file for bash. The first thing this rc file does is to remove itself, meaning it can only be run once. SinceBASH_ENVis 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 breaknix-shell. (link to relevant code)All autocompletion files are sourced from
/etc/bashrcwhich 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 callingc++ --version ..., a bash script which will sourceBASH_ENV. Using strace you can see that all later calls to the rc file fails.Removing
$ENV{BASH_ENV} = $rcfile;fixes the issue (--runstill works). The alternative would be to handle the removal of the temporary file in a different manner.Don't set $BASH_ENV, fixes NixOS#976
Fix early removal of rc-file for nix-shell
deepfire commentedon Aug 23, 2016
Another userspace bug diagnosed by the transcendental powers of
strace!fkz commentedon Aug 24, 2016
#1034 appears to work for me, too, and finally fixes this annoying bug, thanks a lot @hedning !
Fix early removal of rc-file for nix-shell
matthiasbeyer commentedon Nov 21, 2016
Somehow, this issue still exists for me. Can someone tell me step-by-step how to debug this?
olejorgenb commentedon Nov 21, 2016
@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-buildand search for$ENV{BASH_ENV} = $rcfile;If it's present you don't have the fix.shlevy commentedon Nov 21, 2016
@edolstra Can we get a new 1.11 release?