Skip to content

Commit 8ffda08

Browse files
committed
libexpr: Make hash mismatches while copying lazy paths to the store a proper error
This can happen when the local source tree (dirty git repo) gets modified when the nix process is evaluating stuff from it. Make this a proper error and not an assert. I've hit this issue myself once now.
1 parent a3f46f2 commit 8ffda08

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/libexpr/paths.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ void EvalState::ensureLazyPathCopied(const StorePath & path)
4040
FetchMode::Copy,
4141
path.name());
4242

43-
/* Catch hash mismatches more loudly. This is more likely caused by unsound
44-
caching of different accessor types that fetch the same repo with
45-
the same git revision, but with different kinds of accessors (think
46-
tarball-based fetchers vs local/remote git accessors). */
43+
/* This can happen if the source gets modified by another process while we are evaluaing
44+
from it. Alternatively, the caching might be unsound and fetcher cache is poisoned somehow.
45+
See https://github.com/NixOS/nix/issues/14317. */
4746
if (storePath != path) {
48-
panic(fmt(
49-
"hashed store path computed by the evaluator ('%1%') does not match what was computed when copying to the store ('%2%'), this is a bug",
47+
throw Error(
48+
(unsigned int) 102,
49+
"store path ('%1%') was hashed to avoid a full copy at first, but upon reading it again, the contents have changed ('%2%'), so we can not proceed. Make sure files do not change during evaluation",
5050
store->printStorePath(path),
51-
store->printStorePath(storePath)));
51+
store->printStorePath(storePath));
5252
}
5353
}
5454

0 commit comments

Comments
 (0)