aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-12 21:50:50 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-28 00:19:35 +0000
commit4bbd80c5366711b8f1b5ad108ba22206d3bee783 (patch)
treee7d918c75137e59fa0e5fb21a6f720936dfbf7fe
parent73b3e6cd46cf8f10b4c35043d7c0708b22ffebd6 (diff)
Throw error for derivation goal with bogus wanted output
-rw-r--r--src/libstore/build/derivation-goal.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index c29237f5c..530f8829a 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -1243,9 +1243,12 @@ OutputPathMap DerivationGoal::queryDerivationOutputMap()
void DerivationGoal::checkPathValidity()
{
bool checkHash = buildMode == bmRepair;
+ auto wantedOutputsLeft = wantedOutputs;
for (auto & i : queryPartialDerivationOutputMap()) {
InitialOutput & info = initialOutputs.at(i.first);
info.wanted = wantOutput(i.first, wantedOutputs);
+ if (info.wanted)
+ wantedOutputsLeft.erase(i.first);
if (i.second) {
auto outputPath = *i.second;
info.known = {
@@ -1267,6 +1270,11 @@ void DerivationGoal::checkPathValidity()
}
}
}
+ // If we requested all the outputs via the empty set, we are always fine.
+ // If we requested specific elements, the loop above removes all the valid
+ // ones, so any that are left must be invalid.
+ if (!wantedOutputsLeft.empty())
+ throw UsageError("some wanted outputs are not provided by the derivation: %s", concatStringsSep(", ", wantedOutputsLeft));
}