cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.47k stars 252 forks source link

Should $SHELL be set to bashInteractive? #1133

Open jashandeep-sohi opened 2 weeks ago

jashandeep-sohi commented 2 weeks ago

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?

sandydoo commented 2 weeks ago

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

jashandeep-sohi commented 1 week ago

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 commented 1 week ago

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.