Bash is invisible to nix-channel

I have just installed Kubuntu 20.04, and have just installed multi-user Nix 2.3.7. After adding “nixos-20.03” as a channel, when I try “nix-channel --update”, I get the following error:

unpacking channels...
while setting up the build environment: executing '/usr/bin/bash': No such file or directory
builder for '/nix/store/h6x62kwi2i9m0mr8xxzabbldggrv7ph6-nixos-20.03-20.03.2668.7c85b915892.drv' failed with exit code 1
error: build of '/nix/store/h6x62kwi2i9m0mr8xxzabbldggrv7ph6-nixos-20.03-20.03.2668.7c85b915892.drv' failed
error: program '/usr/local/bin/nix-env' failed with exit code 100

I have confirmed that “/usr/bin/bash” exists and works, and I have been unable to find any help that addresses this particular issue. If anything, I have the impression that this may be a permission problem, but if so, I’m not sure what permissions I need…

Any thoughts about what may be going wrong?

/usr/bin/bash may exist locally. But nix packages are built in a sandbox, which won’t contain that path. Try to just use the command name bash if you need to call it. If you need to call a specific version, you can also do ${bash}/bin/bash.

Bash is also located in the “bash” package.

EDIT:
If you need to use it as part of a shebang (which expects an absolute path), then use #!/usr/bin/env bash

How do I set up Nix so that it could find Bash?

Unfortunately, I’m not in a position to install Nix’s Bash: I have just barely installed multi-user Nix, and I initially discovered this problem when I tried something like “nix-env -qa tmux” and found nothing. I had to add a channel by hand.

(I’m somewhat aware that I ought to be able to set this up through a Nix configuration file, but up to this point, my experience is limited to single-user Nix, nix-shell, and a failed attempt to install NixOS on a computer. Now I’m wondering if I missed a step in the installation process…)

Is it normal for nix-env to be in /usr/local/bin when installing Nix on Linux? On Darwin nix-env lives in the Nix store and is exposed via the normal Nix profile mechanism.

Since you’re executing /usr/local/bin/nix-env that makes me wonder if this is a version of Nix that was built manually.

If it was built manually, then in theory if it was configured with --with-sandbox-shell=$shellPath and $shellPath pointed to a file that itself tried to execute /usr/local/bin/bash then that would presumably cause this issue if setting up the build environment executes /bin/sh.

That said, this doesn’t seem like a very likely scenario to hit for someone new to Nix.

This is a version on Nix built manually, but it was the result of following this tutorial:

https://nixos.wiki/wiki/Install_Nix_in_multi-user_mode_on_non-NixOS

Since I was following the tutorial, I didn’t provide any options beyond the “–enable-gc” option requested in the tutorial.

I have run into a couple of package issues while following that tutorial, but I concluded it was because I was trying to install on Kubuntu rather than Debian.

In trying to figure out what I’m doing wrong, I recall reading a thread discussing whether to make Nix multi-user by default, but the discussion settled down to “yes, eventually, but not for now”. If I can install multi-user Nix without having to build manually, I think I’d prefer to do that! :slight_smile:

You shouldn’t need to build anything manually. I don’t know who wrote that tutorial, but you should be able install from binary straight from the manual-provided instructions instead: https://nixos.org/nix/manual/#sect-multi-user-installation. Clean stuff up, and use this.

It’s quite possible that building it yourself caused Nix to pick up dependencies that are not in the Nix store, possibly causing problems.

Jikes. That wiki page probably was probably written before multi-user installs were possible on other Linux distributions. However, multi-user installs are possible with the default installer. So, this page should be removed or updated.

Whay do you tink @makefu ?

On the wiki I prepended a notice directing users to the manual. Hope it’s uncontroversial that the manual is a better source of truth here.

1 Like

After rolling back the attempt to follow the tutorial, I was able to follow the manual without any problems. I’m not entirely sure how I ended up at the tutorial instead of the manual, so I certainly appreciate updating the tutorial to have a link to the manual.

Thanks for the help. It’s greatly appreciated!

I am in favor of removing the original tutorial and linking to the official documentation instead.
We can also add a {{outdated|REASON}} Macro similar to https://nixos.wiki/wiki/NixOS_Installation_Guide/Manual_USB_Creation

TIL about that template. Haven’t really worked with wikis before so didn’t know my way very well. Thanks for the heads up.

I converted the notice to an {{outdated|...}} template.