summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2022-06-11 18:59:38 +0200
committerLudovic Courtès <ludo@gnu.org>2022-06-16 12:50:06 +0200
commitf4041120076f24ba61b69fcd1adf61a7ef4fd81f (patch)
treecf3ad13acc12c46cdedb4ea34a45fd6905761115
parentc48c69cfa34868527e099c6d12458dfa222d010f (diff)
downloadguix-f4041120076f24ba61b69fcd1adf61a7ef4fd81f.tar.gz
channels: Print backtrace when generating package cache fails.
* guix/channels.scm (package-cache-file): Add a throw handler around
the generate-package-cache call, and print backtrace in it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/channels.scm9
1 files changed, 8 insertions, 1 deletions
diff --git a/guix/channels.scm b/guix/channels.scm
index 5f47834c10..ce1a60436f 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -907,7 +907,14 @@ be used as a profile hook."
                 (format (current-error-port)
                         "Generating package cache for '~a'...~%"
                         #$profile)
-                (generate-package-cache #$output))
+                ;; This script runs through (primitive-load), which by default
+                ;; doesn't print backtraces when it encounters an exception,
+                ;; so manually do it.  Use with-throw-handler because it is
+                ;; supported by all Guile versions.
+                (with-throw-handler #t
+                  (lambda () (generate-package-cache #$output))
+                  (lambda (key . args)
+                      (backtrace))))
               (mkdir #$output))))
 
     (gexp->derivation-in-inferior "guix-package-cache" build