From 4cbcaad435b18fff1904757b2e035c9033d647eb Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Thu, 16 Oct 2025 23:08:30 +0300 Subject: [PATCH] libstore/registerOutputs: Don't try to optimize a non-existent actualPath Since 3c610df550be35d9696efe9dd3217a6e1ec100f2 this resulted in `getting status of` errors on paths inside the chroot if a path was already valid. Careful inspection of the logic shows that if buildMode != bmCheck actualPath gets reassigned to store.toRealPath(finalDestPath). The only branch that cares about actualPath is the buildMode == bmCheck case, which doesn't lead to optimisePath anyway. --- src/libstore/unix/build/derivation-builder.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstore/unix/build/derivation-builder.cc b/src/libstore/unix/build/derivation-builder.cc index 8a0fa5ef7..0efdc14b2 100644 --- a/src/libstore/unix/build/derivation-builder.cc +++ b/src/libstore/unix/build/derivation-builder.cc @@ -1742,7 +1742,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs() if (buildMode == bmRepair) { /* Path already exists, need to replace it */ replaceValidPath(store.toRealPath(finalDestPath), actualPath); - actualPath = store.toRealPath(finalDestPath); } else if (buildMode == bmCheck) { /* Path already exists, and we want to compare, so we leave out new path in place. */ @@ -1756,7 +1755,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs() auto destPath = store.toRealPath(finalDestPath); deletePath(destPath); movePath(actualPath, destPath); - actualPath = destPath; } } @@ -1809,7 +1807,9 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs() debug("unreferenced input: '%1%'", store.printStorePath(i)); } - store.optimisePath(actualPath, NoRepair); // FIXME: combine with scanForReferences() + if (!store.isValidPath(newInfo.path)) + store.optimisePath( + store.toRealPath(finalDestPath), NoRepair); // FIXME: combine with scanForReferences() newInfo.deriver = drvPath; newInfo.ultimate = true;