Skip to content

Commit

Permalink
Merge pull request #4587 from obsidiansystems/derivation-goal-detect-…
Browse files Browse the repository at this point in the history
…invalid-output

Throw error for derivation goal with bogus wanted output
  • Loading branch information
edolstra authored Mar 15, 2021
2 parents c0073f6 + 7ce1092 commit ccb8a40
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstore/build/derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,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 = {
Expand All @@ -1274,6 +1277,13 @@ 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 Error("derivation '%s' does not have wanted outputs %s",
worker.store.printStorePath(drvPath),
concatStringsSep(", ", quoteStrings(wantedOutputsLeft)));
}


Expand Down

0 comments on commit ccb8a40

Please sign in to comment.