From 6928c6f952af98a257ddd84eee551a3dda15ab1f Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 30 Nov 2025 14:04:22 +0100 Subject: [PATCH] libstore/store-api: offer more information about drv parsing errors We offer the three usual options: verify, repair then delete and direct people to report us corruption so we can fix if this is induced by us. Fixes #447. Change-Id: I0df61769d732d227333c206f312857c0593f7bce Signed-off-by: Raito Bezarius --- lix/libstore/store-api.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index 4ea7903d1..e34002e12 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -1338,7 +1338,19 @@ try { Derivation::nameFromPath(drvPath) ); } catch (FormatError & e) { - throw Error("error parsing derivation '%s': %s", store.printStorePath(drvPath), e.msg()); + auto drvPathS = store.printStorePath(drvPath); + throw Error( + fmt("error parsing derivation '%1%': %2%\n" + "This can occur when the derivation is corrupted.\n" + "You can check this with `nix-store --verify-path %1%` and possibly repair with " + "`nix-store --repair-path %1%`.\n" + "In case the repair cannot be done, `nix-store --delete %1%` may be able " + "to remove the broken path.\n" + "We would appreciate a bug report at " + "https://git.lix.systems/lix-project/lix/issues if you think this is a bug.", + drvPathS, + e.msg()) + ); } } catch (...) { co_return result::current_exception();