-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 doesn't work right with nixpkgs' own bash #730
Comments
I regularly use |
That's a useful workaround, but I'd love if nix-shell could figure this out by default, as it's really not obvious where the errors come from (I assumed for a long time that it was something in my .bashrc or something, as I had no idea there even was a Also, it just doesn't feel very nix-y that |
looking at the source code, there's the NIX_BUILD_SHELL environment variable that can be used for this (and grepping the nix source reveals it's only used at this point) (I think this would be your third proposed fix). If it's not set, it defaults to the bash in PATH. |
hm, NIX_BUILD_SHELL isn't used when using --pure. I would consider this a bug. |
Thinking a little bit more about it, at least for me the problem most of the time is not nix-shell in (something similiar to) nix-shell but simply bash in nix-shell. My use case is mostly starting IDEs inside nix-shell which in turn start a terminal window. That's of cause a different use case than yours; and here adding bashInteractive seems like the right thing to do. Could be better documented still. |
I swear there was another issue in this, more generally whether there should be a custom list of environment variables that are supposed to leak. In any event I agreee with your last post. I'm this specific case I think it would be cleaner to have nix-shell make the derivation based off the value of NIX_BUILD_SHELL rather than leak the variable itself. |
you're probably right, that's similiar to how it's done with PATH, we get the bash from PATH but don't propagate PATH itself; I guess we should do it like that with NIX_BUILD_SHELL too (in the --pure case) (we can't use nix-shell after that anyway because it's not in the PATH anymore and even if it was ( Custom environment variables sound interesting too, we could do things like propagate X11 or pulseaudio and still using --pure. But that's a little off topic here. |
Sure I could see using |
I'd be happy if $NIX_BUILD_SHELL could be used with --pure, as in #733, thanks @fkz. I'd be happier if it used bashInteractive by default, but I can see how that might be outside of its responsibilities. Another alternative would be to always looks for a system bash (/bin/bash, /usr/bin/bash) before falling back to $PATH. It'd be more code, and would be thoroughly surprising for anyone who has their preferred bash elsewhere on $PATH, although that should be very rare. Thoughts? |
this is also related to #498 and #545 and NixOS/nixpkgs#4260. |
We could also use the user's shell. This currently only works if this is bash. I think the clearest solution would be to use the bash from stdenv. We already include $stdenv/setup, so maybe stdenv could also export an interactive bash (maye $bash or $bashInteractive). That way we'd depend on the same bash from the nixpkgs that's available in the package we install; not some other nixpkgs. |
I don't think that's a good idea - I use
Is that going to cause a new bashInteractive dependency on every new derivation via the stdenv? If so, it sounds like that also removes the point of maintaining separate |
I just used this beast expression to get a nice
|
Hi, I also use fish so something like |
@kc1212 |
This issue is the first Google result for "nix bash: complete: command not found", so let me note that if you're seeing such error messages with Nix's bash, you may want to install "bash-interactive" rather than "bash". |
No one in this thread has suggested that the |
Yes that's a good point. Or stop making the non-interactive bash default. As a user I'm expecting to get bash when running |
Fixed by c94f3d5. |
Thanks! Looking at the code you added, I don't see anything that will add I wrote up some of my thoughts on related nix-shell issues here: My recommendations came down to this: make |
I agree this is unfortunate. But know it was already coupled because |
Yes, I noticed that one too. nix-shell will check if |
@DavidEGrayson Right. At the core nix derivation run some command in some environment. We have |
^ working shell
But if I use nixpkgs' own bash:
^ weird prompt, no readline support, errors printed
This happens reliably when you run
nix-shell
from insidenix-shell
, since most derivations implicitly rely on bash. I run into it all the time when I runnix-shell
from a dir where I'm usingdirenv
to set up project-specific dependencies, since that acts a lot likenix-shell
.I'm not really sure what the right fix is, but I can think of a few options:
nix-shell
explicitly invokepkgs.bashInteractive
rather than whatever's available on$PATH
. I think it should do this by default if possible, but it could also be behind a flagnix-shell
invoke the firstbash
on$PATH
which wasn't compiled with--disable-readline
(although this may not even be possible)nix-shell
accept an explicit path-to-bash argument so that it doesn't have to do either of the above (requires most work from the user though)The text was updated successfully, but these errors were encountered: