diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index e9e1fe4b1ef089ae9f0bc813215e93e53fbbffe3..31011cd7c3db6c4092f6b6a6b59e21f23e8d05fd 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3685,7 +3685,7 @@ void DerivationGoal::registerOutputs()
                 worker.hashMismatch = true;
                 delayedException = std::make_exception_ptr(
                     BuildError("hash mismatch in fixed-output derivation '%s':\n  wanted: %s\n  got:    %s",
-                        dest, h.to_string(), h2.to_string()));
+                        dest, h.to_string(SRI), h2.to_string(SRI)));
 
                 Path actualDest = worker.store.toRealPath(dest);