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

Should $SHELL be set to bashInteractive? #1133

Open
jashandeep-sohi opened this issue Apr 15, 2024 · 3 comments
Open

Should $SHELL be set to bashInteractive? #1133

jashandeep-sohi opened this issue Apr 15, 2024 · 3 comments
Labels
question Further information is requested

Comments

@jashandeep-sohi
Copy link
Contributor

I'm using Flakes to enter devenv shells (i.e. https://devenv.sh/guides/using-with-flake-parts/).

An issue I'm running into is that I'm seeing the following errors whenever tools in the devenv try to do something with a shell:

bash: bind: command not found
bash: complete: command not found

I think this is because nix develop sets $SHELL to ${pkgs.bash}/bin/bash instead of ${pkgs.bashInteractive}/bin/bash.

I can get rid of these errors by explicitly setting $SHELL:

enterShell = ''
  export SHELL=${pkgs.bashInteractive}/bin/bash
'';

Which is fine doing it once or twice, but I'm finding it tedious to do for every project I work on.

So the question is, should devenv be setting the $SHELL environment variable by default to the bashInteractive variant of bash? Or is there some other way of avoiding these errors that doesn't require me setting $SHELL in every devenv?

@jashandeep-sohi jashandeep-sohi added the question Further information is requested label Apr 15, 2024
@sandydoo
Copy link
Member

What OS are you using? And what is SHELL set to before nix develop?

@jashandeep-sohi
Copy link
Contributor Author

What OS are you using? And what is SHELL set to before nix develop?

I'm on Archlinux. It's set to /bin/bash before nix develop.

But I would hope that this behavior should be independent of the OS, since this is one of main reason for using devenv in the first place.

@sandydoo
Copy link
Member

But I would hope that this behavior should be independent of the OS, since this is one of main reason for using devenv in the first place.

Well, you never know 😄 On Nix-managed systems, you can get stuff like starship working in nix develop. Lots of opportunity for breakage.

It appears that Nix launches an interactive shell as a QOL improvement, but the SHELL var remains set to the non-interactive bash builder. mkShell also adds stdenv to the shell, so the bash in PATH in also non-interactive.

We could set SHELL to the interactive version in enterShell and also add bashInteractive to `packages.

However, in devenv test, the launched shell is non-interactive. So the above changes would invert the problem there. Not sure what the side-effects would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants