Merge pull request #211082 from hercules-ci/fix-issue-16182
Fix issue 16182 `Error: _assignFirst found no valid variant!`
This commit is contained in:
commit
a1cd06f900
@ -253,7 +253,7 @@ The propagated equivalent of `depsTargetTarget`. This is prefixed for the same r
|
||||
|
||||
#### `NIX_DEBUG` {#var-stdenv-NIX_DEBUG}
|
||||
|
||||
A natural number indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing.
|
||||
A number between 0 and 7 indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing.
|
||||
|
||||
### Attributes affecting build properties {#attributes-affecting-build-properties}
|
||||
|
||||
|
@ -4,16 +4,32 @@ preFixupHooks+=(_multioutDocs)
|
||||
preFixupHooks+=(_multioutDevs)
|
||||
postFixupHooks+=(_multioutPropagateDev)
|
||||
|
||||
# Assign the first string containing nonempty variable to the variable named $1
|
||||
# _assignFirst varName otherVarNames*
|
||||
#
|
||||
# Set the value of the variable named $varName to the first of otherVarNames
|
||||
# that refers to a non-empty variable name.
|
||||
#
|
||||
# If none of otherVarNames refers to a non-empty variable, the error message is
|
||||
# specific to this function's use case, which is setting up the output variables.
|
||||
_assignFirst() {
|
||||
local varName="$1"
|
||||
local REMOVE=REMOVE # slightly hacky - we allow REMOVE (i.e. not a variable name)
|
||||
shift
|
||||
while (( $# )); do
|
||||
if [ -n "${!1-}" ]; then eval "${varName}"="$1"; return; fi
|
||||
shift
|
||||
for var in "$@"; do
|
||||
if [ -n "${!var-}" ]; then eval "${varName}"="${var}"; return; fi
|
||||
done
|
||||
echo "Error: _assignFirst found no valid variant!"
|
||||
echo
|
||||
echo "error: _assignFirst: could not find a non-empty variable to assign to ${varName}."
|
||||
echo " The following variables were all unset or empty:"
|
||||
echo " $*"
|
||||
if [ -z "${out:-}" ]; then
|
||||
echo ' If you do not want an "out" output in your derivation, make sure to define'
|
||||
echo ' the other specific required outputs. This can be achieved by picking one'
|
||||
echo " of the above as an output."
|
||||
echo ' You do not have to remove "out" if you want to have a different default'
|
||||
echo ' output, because the first output is taken as a default.'
|
||||
echo
|
||||
fi
|
||||
return 1 # none found
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,14 @@ echo "testBuildFailure: Original builder produced exit code: $r"
|
||||
# -----------------------------------------
|
||||
# Write the build log to the default output
|
||||
|
||||
getAllOutputNames() {
|
||||
if [ -n "$__structuredAttrs" ]; then
|
||||
echo "${!outputs[*]}"
|
||||
else
|
||||
echo "$outputs"
|
||||
fi
|
||||
}
|
||||
|
||||
outs=( $(getAllOutputNames) )
|
||||
defOut=${outs[0]}
|
||||
defOutPath=${!defOut}
|
||||
|
@ -4,7 +4,8 @@
|
||||
{ stdenv
|
||||
, pkgs
|
||||
, lib
|
||||
,
|
||||
, runCommand
|
||||
, testers
|
||||
}:
|
||||
|
||||
let
|
||||
@ -99,6 +100,25 @@ in
|
||||
# tests for hooks in `stdenv.defaultNativeBuildInputs`
|
||||
hooks = lib.recurseIntoAttrs (import ./hooks.nix { stdenv = bootStdenv; pkgs = earlyPkgs; });
|
||||
|
||||
outputs-no-out = runCommand "outputs-no-out-assert" {
|
||||
result = testers.testBuildFailure (stdenv.mkDerivation {
|
||||
NIX_DEBUG = 1;
|
||||
name = "outputs-no-out";
|
||||
outputs = ["foo"];
|
||||
buildPhase = ":";
|
||||
installPhase = ''
|
||||
touch $foo
|
||||
'';
|
||||
});
|
||||
|
||||
# Assumption: the first output* variable to be configured is
|
||||
# _overrideFirst outputDev "dev" "out"
|
||||
expectedMsg = "_assignFirst: could not find a non-empty variable to assign to outputDev. The following variables were all unset or empty: dev out.";
|
||||
} ''
|
||||
grep -F "$expectedMsg" $result/testBuildFailure.log >/dev/null
|
||||
touch $out
|
||||
'';
|
||||
|
||||
test-env-attrset = testEnvAttrset { name = "test-env-attrset"; stdenv' = bootStdenv; };
|
||||
|
||||
# Test compatibility with derivations using `env` as a regular variable.
|
||||
|
Loading…
Reference in New Issue
Block a user