Describe the bug
Since this commit:
https://github.com/NixOS/nixpkgs/commit/bbc5b22ad82f89d2605ab91073012b12cabe87c3
Whenever I run commands like:
nix-shell -p hello
I get the following error:
/nix/store/v94xrmhkljhb44v2shcpv74gxg1ii1f1-cctools-binutils-darwin-wrapper/nix-support/setup-hook: line 140: ${role_pre}${cmd^^}=${cmd}: bad substitution
Additional context
My default shell is zsh, which has been the cause of some issues at times.
Metadata
- system: `"x86_64-darwin"`
- host os: `Darwin 18.7.0, macOS 10.14.6`
- multi-user?: `no`
- sandbox: `no`
- version: `nix-env (Nix) 2.3.1`
- channels(root): `""`
- channels(val): `"nixpkgs-20.03pre197510.4b0508a5853"`
- nixpkgs: `/Users/val/.nix-defexpr/channels/nixpkgs`
Paging @xzfc in particular. Let me know how I can help!
You need recent bash (>=4) as macOS has outdated bash by default.
I'm not sure how nix behaves on macOS, but try either of the following:
$NIX_BUILD_SHELL
environment variable, unset it.unset NIX_BUILD_SHELL; nix-shell -p hello
export NIX_BUILD_SHELL=$(nix-build -A bashInteractive '<nixpkgs>')/bin/bash; nix-shell -p hello
nix-env -iA nixpkgs.bashInteractive
Thanks. I personally solved it by:
brew update
brew install bash
Which installed an ambient bash v5.0.
Feel free to close this if you think you're done tracking this concern.
Nix should use bashInteractive from Nixpkgs. I suspect it's hitting some error and falling back here:
Thanks. I personally solved it by:
brew update brew install bash
I could also solve the issue for me with these steps.
@matthewbauer I got this issue on macOS, and installing via @xzfc's comment worked out well (which was also the solution you mentioned). I am running macOS Catalina, and wanted a pure nix/macOS machine, so for me this was a better solution.
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Most helpful comment
Thanks. I personally solved it by:
Which installed an ambient bash v5.0.
Feel free to close this if you think you're done tracking this concern.