-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
stdenv: bump required Bash version from 4 to 5 #340765
Conversation
Currently stdenv requires Bash 4.x that was released in 2009. This change bumps the required version to Bash 5.x (2019, 5 years ago). See https://mywiki.wooledge.org/BashFAQ/061 for more details. Using a relatively modern Bash version allows us to rely on newer features (e.g. ${var@a}) and remove workarounds for older quirks (e.g. https://stackoverflow.com/a/7577209, “old bash empty array problem”). Note that many setup hooks are using features added after 4.0 version, e.g. makeWrapper uses ${var@Q} from 4.4, but some even require >5.0, e.g. cargoBuildHook uses ${var@U} from 5.1.
Honestly it’s unclear to me why we even support Bash versions other than the one in Nixpkgs. I guess with direnv or similar you can end up loading stdenv stuff into a non‐Nixpkgs shell, but we already don’t support e.g. macOS’s Bash version. (In other words, 👍) |
IIRC |
cc @roberth in case you know of some other cases on the Nix side that this change may affect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support this change. I do think that it deserves a mention in the stdenv docs, likely in the "Tools provided by stdenv
" section.
If we use features that require bash 4.4 or bash 5, we can't claim to support bash 4, so 👍.
Does this mean we need to check for at least 5.1, too? |
cc @reckenrode for a view from the Darwin side? I think the main reason this was not done for long was due to Darwin, but I don't know any details. |
macOS ships an ancient Bash claiming to be 3.2.57(1)-release, so I don’t think there’s a reason for it to block here. IIRC it might backport some Bash 4 features, but I doubt enough to make things actually work, and it would trigger the previous error anyway. |
Apple ships an ancient Bash because Apple stopped updating GNU tools when they switched to GPLv3. Others have been replaced (e.g., libiconv, patch_cmds), but Apple continues to ship the ancient Bash along with Zsh instead of replacing it. I don’t know why Darwin was an issue in the past. It’s possible that the bootstrap tools shipped Bash 4, but they were updated in #302387, so that should not be an issue. The bootstrap tools now have Bash 5.2. The Darwin bootstrap also rebuilds Bash very early and uses that in preference to the bootstrap tools Bash. |
In this particular case, we can use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I think this is good.
I expect no issues despite Nix's bad coupling with stdenv, which it shouldn't have. In Nixpkgs we now have |
Description of changes
Currently stdenv requires Bash 4.x that was released in 2009. This change bumps the required version to Bash 5.x (2019, 5 years ago).
See https://mywiki.wooledge.org/BashFAQ/061 for more details.
Using a relatively modern Bash version allows us to rely on newer features (e.g. ${var@a}) and remove workarounds for older quirks (e.g. https://stackoverflow.com/a/7577209, “old bash empty array problem”). Note that many setup hooks are using features added after 4.0 version, e.g. makeWrapper uses ${var@Q} from 4.4, but some even require Bash >5.0, e.g. cargoBuildHook uses ${var@U} from 5.1.
References:
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.