From 70bcd6a55ccf583858342c2a1be6efe30167759c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 29 Apr 2020 15:42:53 +0200 Subject: [PATCH] Evaluation cache: Don't barf in read-only mode Fixes $ nix copy warning: Git tree '/home/eelco/Dev/nix-flake' is dirty nix: src/nix/installables.cc:348: std::tuple, std::allocator >, nix::FlakeRef, nix::InstallableValue::DerivationInfo> nix::InstallableFlake::toDerivation(): Assertion `state->store->isValidPath(drvPath)' failed. Aborted (core dumped) --- src/nix/installables.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 6b9e2ee96..c2e2a6573 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -339,12 +339,14 @@ std::tuple InstallableF auto aDrvPath = attr->getAttr(state->sDrvPath); auto drvPath = state->store->parseStorePath(aDrvPath->getString()); - if (!state->store->isValidPath(drvPath)) { + if (!state->store->isValidPath(drvPath) && !settings.readOnlyMode) { /* The eval cache contains 'drvPath', but the actual path has been garbage-collected. So force it to be regenerated. */ aDrvPath->forceValue(); - assert(state->store->isValidPath(drvPath)); + if (!state->store->isValidPath(drvPath)) + throw Error("don't know how to recreate store derivation '%s'!", + state->store->printStorePath(drvPath)); } auto drvInfo = DerivationInfo{