Skip to content
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

treewide: set -u everywhere #72347

Merged
merged 13 commits into from
Nov 5, 2019
Merged

treewide: set -u everywhere #72347

merged 13 commits into from
Nov 5, 2019

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Oct 31, 2019

2 years or so ago I made stdenv and cc-wrapper use set -u, which enormously helped with debugging. But I didn't want to change all of nixpkgs so I added lots of temporary set +u-ing.

Well, I think it's now time to bring the benefit to all of nixpkgs. Why? Because we have another big repo-wide refactor going on #72074. This will make that much easier to debug, and hopefully get some momentum going for stdenv tech debt fixing. Everyone chip in!

In particular, I think this is the easiest stdenv refactor we'd like to make, Why? This has the nice property that programs that continue to not fail have the same behavior. [Actually, this is not true with trap to catch failures or no set -e, but we use set -e and still fail after trap-ing.] That means it's very easy to debug; no getting a bunch of things working only to find some deeper dependency was built wrong and needing to backtrack, and no needing to debug complex failures.

I swear there was an issue for thus, but I couldn't find it.

Hydra job: https://hydra.nixos.org/jobset/nixpkgs/bash-no-undef-vars#tabs-evaluations

TODO:

  • Fix the broken things

  • Write release notes

@Ericson2314 Ericson2314 changed the base branch from master to staging October 31, 2019 02:34
@ofborg ofborg bot added 6.topic: qt/kde 6.topic: stdenv Standard environment labels Oct 31, 2019
@Ericson2314 Ericson2314 changed the title treewide: set -u everywhere treewide: set -u everywhere Oct 31, 2019
@FRidh

This comment has been minimized.

@Mic92
Copy link
Member

Mic92 commented Oct 31, 2019

This should be also mentioned in the release notes as it can break out-of-tree packages.

@Ericson2314 Ericson2314 changed the title treewide: set -u everywhere WIP: treewide: set -u everywhere Oct 31, 2019
@Ericson2314
Copy link
Member Author

Wow, is there no way to mark a PR draft after the fact?!?! Embarrising, GitHub.

@c0bw3b c0bw3b added the 2.status: work-in-progress This PR isn't done label Oct 31, 2019
@ofborg ofborg bot added 6.topic: rust 2.status: merge conflict This PR has merge conflicts with the target branch labels Nov 1, 2019
@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation labels Nov 1, 2019
@Ericson2314
Copy link
Member Author

Ericson2314 commented Nov 1, 2019

Hydra reached the point where the legitimate failures were buried amidst all sorts of spurious failures. This makes it harder to use it. I think it might be ready to go to staging then, at least after this these newer evals get further? @globin @matthewbauer What do you think?

@Ericson2314 Ericson2314 changed the title WIP: treewide: set -u everywhere treewide: set -u everywhere Nov 2, 2019
@Ericson2314
Copy link
Member Author

https://hydra.nixos.org/eval/1552118?compare=1551936&full=1#tabs-now-fail here is a comparison to the base commit, which is a nixpkgs-unstable eval.

My earlier sed missed this because it already had `{..}`.
I don't want to just rebase this away because the original commit is
also in #72074.
@FRidh
Copy link
Member

FRidh commented Nov 5, 2019

Darwin fails on the bash-no-undef-vars branch https://hydra.nixos.org/build/105765822

@Ericson2314
Copy link
Member Author

Ericson2314 commented Nov 5, 2019

@FRidh that is a commit pushed post merge. The job is now just for #72812 . Do ping me with any/all set -u related failures on staging though, and I will try to watch it too.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-weekly-14-hercules-ci-launch-performance-improvements-in-nixpkgs-single-dependency-kubernetes-clusters/4769/1

@Mic92
Copy link
Member

Mic92 commented Nov 19, 2019

qt needs a fix: #73586 (comment) in pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh

untested patch:

diff --git a/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh b/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
index 35982e86628..0ad185a16eb 100644
--- a/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
+++ b/pkgs/development/libraries/kde-frameworks/extra-cmake-modules/setup-hook.sh
@@ -77,6 +77,8 @@ ecmUnseenHostPath() {
 ecmHostPathHook() {
     ecmUnseenHostPath "$1" || return 0
 
+    declare -a qtWrapperArgs
+
     local xdgConfigDir="$1/etc/xdg"
     if [ -d "$xdgConfigDir" ]
     then

@FRidh
Copy link
Member

FRidh commented Nov 19, 2019

qtWrapperArgs is fixed with ef43c5f. Now there are issues left with the setup hooks of both plasma5 packages and kdeFrameworks packages.
pkgs/desktops/plasma-5/default.nix
pkgs/development/libraries/kde-frameworks/default.nix
Looked into this briefly, #73756

@veprbl veprbl removed the 2.status: work-in-progress This PR isn't done label Nov 19, 2019
@Ericson2314
Copy link
Member Author

Actually my commit could not be enough, but @Mic92's won't work either. The issue is bash says an undefined variable and and undefined variable are the same thing (which is terrible!!!).

The direct workaround is awful ${foo+${foo[@]}}, but thankfully there are other ways like ${#foo[@]} to get the same result.

jtojnar referenced this pull request Dec 29, 2019
Bash takes an assignment of a string to an array variable:

local -a user_args
user_args="(foo bar)"

to mean appending the string to the array, not parsing the string into
an array as is the case when on the same line as the declaration:

local -a user_args="(foo bar)"

b063340 extracted the declaration before
the newly branched code block, causing string makeWrapperArgs being added
to the array verbatim.

Since local is function scoped, it does not matter if we move it inside
each of the branches so we fix it this way.
@jtojnar
Copy link
Member

jtojnar commented Dec 29, 2019

Hmm, it appears this is not enough. For example wrapPython setup hook is running with +o nounset: a6bb2ed#commitcomment-36605469

In fact, when I comment out

# Disable nounset for nix-shell.
set +u

and try to build python3.pkgs.setuptools, it fails on trying to build xz:

/nix/store/aknix5zw9cj7hd1m3h1d6nnmncl1vkvn-multiple-outputs.sh: line 55: shareDocName: unbound variable

@Ericson2314
Copy link
Member Author

Indeed the work isn't done! https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L1307-L1308 needs to be guarded by IN_NIX_SHELL so it doesn't mess up normal builds.

I should have made an issue earlier when I realized this, but didn't have the time to immediately start fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python 6.topic: qt/kde 6.topic: ruby 6.topic: rust 6.topic: stdenv Standard environment 8.has: changelog 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ 10.rebuild-darwin: 5001+ 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ 10.rebuild-linux-stdenv This PR causes stdenv to rebuild
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants