1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

--check: Fix assertion failure when some outputs are missing

E.g.

  $ nix-build pkgs/stdenv/linux/ -A stage1.pkgs.perl --check
  nix-store: src/libstore/build.cc:1323: void nix::DerivationGoal::tryToBuild(): Assertion `buildMode != bmCheck || validPaths.size() == drv->outputs.size()' failed.

when perl.out exists but perl.man doesn't. The fix is to only check
the outputs that exist. Note that "nix-build -A stage1.pkgs.all
--check" will still give a (proper) error in this case.
This commit is contained in:
Eelco Dolstra 2016-01-12 14:54:39 +01:00
parent ef7c2d8b3e
commit 1c57ab8b31

View file

@ -1326,7 +1326,6 @@ void DerivationGoal::tryToBuild()
now hold the locks on the output paths, no other process can now hold the locks on the output paths, no other process can
build this derivation, so no further checks are necessary. */ build this derivation, so no further checks are necessary. */
validPaths = checkPathValidity(true, buildMode == bmRepair); validPaths = checkPathValidity(true, buildMode == bmRepair);
assert(buildMode != bmCheck || validPaths.size() == drv->outputs.size());
if (buildMode != bmCheck && validPaths.size() == drv->outputs.size()) { if (buildMode != bmCheck && validPaths.size() == drv->outputs.size()) {
debug(format("skipping build of derivation %1%, someone beat us to it") % drvPath); debug(format("skipping build of derivation %1%, someone beat us to it") % drvPath);
outputLocks.setDeletion(true); outputLocks.setDeletion(true);
@ -2747,6 +2746,7 @@ void DerivationGoal::registerOutputs()
PathSet references = scanForReferences(actualPath, allPaths, hash); PathSet references = scanForReferences(actualPath, allPaths, hash);
if (buildMode == bmCheck) { if (buildMode == bmCheck) {
if (!store->isValidPath(path)) continue;
ValidPathInfo info = worker.store.queryPathInfo(path); ValidPathInfo info = worker.store.queryPathInfo(path);
if (hash.first != info.hash) if (hash.first != info.hash)
throw Error(format("derivation %1% may not be deterministic: hash mismatch in output %2%") % drvPath % path); throw Error(format("derivation %1% may not be deterministic: hash mismatch in output %2%") % drvPath % path);