From 9ccbe23056bb7cd81a762fcefb093f8a97dac8f0 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 15 Aug 2025 01:19:22 -0400 Subject: [PATCH] `DerivationBuilder` Change missing `initialOutput` `if..throw` to `assert` Since this goal has no (goal-wide) notion of "wanted outputs" (we're building the derivation, and thus making all outputs), we should have `initialOutputs` for all outputs, and if we're missing one that's an internal error caused by a bug in Nix. Concretely, `DerivationBuildingGoal::gaveUpOnSubstitution` now clearly does create `initialOutputs` for all outputs, whereas a few commits ago that was not obvious, so I feel confident in saying that this invariant that should be upheld, in fact is upheld. `scatchOutputs` is initialized for every initial output, so the same change to it follows for the same reasons. --- src/libstore/unix/build/derivation-builder.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libstore/unix/build/derivation-builder.cc b/src/libstore/unix/build/derivation-builder.cc index c6027ed61..3ea208924 100644 --- a/src/libstore/unix/build/derivation-builder.cc +++ b/src/libstore/unix/build/derivation-builder.cc @@ -1456,18 +1456,14 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs() std::map outputStats; for (auto & [outputName, _] : drv.outputs) { auto scratchOutput = get(scratchOutputs, outputName); - if (!scratchOutput) - throw BuildError( - "builder for '%s' has no scratch output for '%s'", store.printStorePath(drvPath), outputName); + assert(scratchOutput); auto actualPath = realPathInSandbox(store.printStorePath(*scratchOutput)); outputsToSort.insert(outputName); /* Updated wanted info to remove the outputs we definitely don't need to register */ auto initialOutput = get(initialOutputs, outputName); - if (!initialOutput) - throw BuildError( - "builder for '%s' has no initial output for '%s'", store.printStorePath(drvPath), outputName); + assert(initialOutput); auto & initialInfo = *initialOutput; /* Don't register if already valid, and not checking */