Open bew opened 2 years ago
oh and centos7 is still 2 years away from end of life. Do you want to add a guard for bash version 4 ? Sorry about the breakage!
Do you want to add a guard for bash version 4 ?
Yes I think that would be enough, and maybe move this after the bash version >=4 check. The option have been added in 4.4 (ref), not sure how to test for this, maybe there's a way to check if the option exists?
I'm not familiar with making large-impact changes like this on stdenv, so i would prefer not to do/try it..
actually the best might be to just ignore errors on that command. Probably add a comment to remove that when centos7 goes end of life.
something like adding 2>&1 || true
something like adding
2>&1 || true
This seems to work indeed when I do the change locally (and it tries to rebuild the world...)
Just for information, usually the process to making a PR to stdenv is
make a PR against the staging branch with your changes.
People will review it, and then it gets added to the list of changes on the next staging-next
iteration. Problems sometimes appear during the staging-next
PR (which is just a group of staging changes together in a PR).
You don't need to try to rebuild everything on the PR as it would build too much, usually, you try to build a basic dependency like perl and if that works, then you leave the rest of the build to the staging-next
PR.
similar error here in m1 macos.
nix-shell -p nix-info --run "nix-info -m" -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
/nix/store/2j6pxz2dk7xx0jw6jc60rizk46i4r5v1-stdenv-darwin/setup: line 20: shopt: inherit_errexit: invalid shell option name
/private/tmp/nix-shell-50792-0/rc: line 1: rm: No such file or directory
update bash solved it
@soulomoon what is the default bash version running on m1 ? I thought they didn't have bash anymore. Just curious.
@happysalada that would be bash 3.2 (
Actually now that I think about it, there are things later in stdenv that do require a modern version of bash. Perhaps the best here would be to check on the version and exit early with a helpful message. My only problem is that stdenv runs with both sh (in the bootstrapping stage) and bash (after bootstrapping). So the function would need to take the 2 things into account. I'm going to think about this and try to find time next weekend.
I have run into the same issue:
$ echo ${BASH_VERSION}
4.2.46(2)-release
$ nix-shell -p nix-info
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
/nix/store/ym0rxxcd2kjcfbazpv7kqyk2mjfmihna-nix-info
copying path '/nix/store/ym0rxxcd2kjcfbazpv7kqyk2mjfmihna-nix-info' from 'https://cache.nixos.org'...
/nix/store/523zlfzypzcr969p058i6lcgfmg889d5-stdenv-linux/setup: line 14: shopt: inherit_errexit: invalid shell option name
/tmp/nix-shell-4449-0/rc: line 1: rm: No such file or directory
I can't update bash. Is there anything else I can do?
Describe the bug
On a non-NixOS distrib, when there is no
nixpkgs
in the flake registry or in$NIX_PATH
,nix-shell
falls back to thebash
in the system.When the bash version is 4 (like on CentOS7), I get the error:
bash: shopt: inherit_errexit: invalid shell option name
(see reproduction steps for more)NOTE: I removed
nixpkgs
from the registry to always ensure I use my pinned version, and I have full control on where my packages comes from. No hidden global state!Steps To Reproduce
Steps to reproduce the behavior:
Write a simple
mkShell
invocation:In a file
foo.nix
:Running
nix-shell foo.nix
I get:=> I'm back to my initial shell, It didn't enter the nix-shell.
Expected behavior
Enter the nix-shell without error!
Additional context: bash version
Additional context: PR introducing the failing option
The
inherit_errexit
shell option was added in #139508.It's set unconditionally: https://github.com/NixOS/nixpkgs/blob/82500ee3bc3f8c36a7f95bd9b8a076139ab1039d/pkgs/stdenv/generic/setup.sh#L3-L9 And proceeds to check the bash version is >= 4 just after.
My take would be to set this option only for bash version > 4. (or whatever version this was added in)
Notify maintainers
Metadata