diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 566903ed732012dd4667497a8e8749a7548abfc1..9035280577e17241f8f99190ee42d93041900fc0 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -50,7 +50,10 @@ (define* (set-paths #:key inputs #:allow-other-keys)
   (let ((inputs (map cdr inputs)))
     (set-path-environment-variable "PATH" '("bin") inputs)
     (set-path-environment-variable "CPATH" '("include") inputs)
-    (set-path-environment-variable "LIBRARY_PATH" '("lib" "lib64") inputs)))
+    (set-path-environment-variable "LIBRARY_PATH" '("lib" "lib64") inputs)
+
+    ;; Dump the environment variables as a shell script, for handy debugging.
+    (system "export > environment-variables")))
 
 (define* (unpack #:key source #:allow-other-keys)
   (and (zero? (system* "tar" "xvf" source))