aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-22 17:07:14 -0700
committerJade Lovelace <lix@jade.fyi>2024-08-23 17:49:15 -0700
commit686120ee4a34f658b2f19dcac9f9dc44dbc98b93 (patch)
tree9c688afa704afc91724fdad259de4f3e447b6699 /src
parentc5949bfe313a92aab0e4cf38ab2407b0ac922ce8 (diff)
fix: good errors for failures caused by allowSubstitutes
This caused an absolute saga which I would not like anyone else to have to experience. Let's put in a laser targeted error message that diagnoses this exact problem. Fixes: https://git.lix.systems/lix-project/lix/issues/484 Change-Id: I2a79f04aeb4a1b67c10115e5e39501d958836298
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build/derivation-goal.cc37
-rw-r--r--src/libstore/build/local-derivation-goal.cc24
2 files changed, 38 insertions, 23 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index f31c3acd5..0f082b193 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -261,24 +261,29 @@ Goal::WorkResult DerivationGoal::haveDerivation(bool inBuildSlot)
through substitutes. If that doesn't work, we'll build
them. */
WaitForGoals result;
- if (settings.useSubstitutes && parsedDrv->substitutesAllowed())
- for (auto & [outputName, status] : initialOutputs) {
- if (!status.wanted) continue;
- if (!status.known)
- result.goals.insert(
- worker.makeDrvOutputSubstitutionGoal(
- DrvOutput{status.outputHash, outputName},
- buildMode == bmRepair ? Repair : NoRepair
- )
- );
- else {
- auto * cap = getDerivationCA(*drv);
- result.goals.insert(worker.makePathSubstitutionGoal(
- status.known->path,
- buildMode == bmRepair ? Repair : NoRepair,
- cap ? std::optional { *cap } : std::nullopt));
+ if (settings.useSubstitutes) {
+ if (parsedDrv->substitutesAllowed()) {
+ for (auto & [outputName, status] : initialOutputs) {
+ if (!status.wanted) continue;
+ if (!status.known)
+ result.goals.insert(
+ worker.makeDrvOutputSubstitutionGoal(
+ DrvOutput{status.outputHash, outputName},
+ buildMode == bmRepair ? Repair : NoRepair
+ )
+ );
+ else {
+ auto * cap = getDerivationCA(*drv);
+ result.goals.insert(worker.makePathSubstitutionGoal(
+ status.known->path,
+ buildMode == bmRepair ? Repair : NoRepair,
+ cap ? std::optional { *cap } : std::nullopt));
+ }
}
+ } else {
+ trace("skipping substitute because allowSubstitutes is false");
}
+ }
if (result.goals.empty()) { /* to prevent hang (no wake-up event) */
return outputsSubstitutionTried(inBuildSlot);
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index 1e3c4109d..dadda4de2 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -436,13 +436,23 @@ std::set<int> LocalDerivationGoal::startBuilder()
killSandbox(false);
/* Right platform? */
- if (!parsedDrv->canBuildLocally(worker.store))
- throw Error("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}",
- drv->platform,
- concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
- worker.store.printStorePath(drvPath),
- settings.thisSystem,
- concatStringsSep<StringSet>(", ", worker.store.systemFeatures));
+ if (!parsedDrv->canBuildLocally(worker.store)) {
+ HintFmt addendum{""};
+ if (settings.useSubstitutes && !parsedDrv->substitutesAllowed()) {
+ addendum = HintFmt("\n\nHint: the failing derivation has %s set to %s, forcing it to be built rather than substituted.\n"
+ "Passing %s to force substitution may resolve this failure if the path is available in a substituter.",
+ "allowSubstitutes", "false", "--always-allow-substitutes");
+ }
+ throw Error({
+ .msg = HintFmt("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}%s",
+ drv->platform,
+ concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
+ worker.store.printStorePath(drvPath),
+ settings.thisSystem,
+ concatStringsSep<StringSet>(", ", worker.store.systemFeatures),
+ Uncolored(addendum))
+ });
+ }
/* Create a temporary directory where the build will take
place. */