[PATCH] channels: Print backtrace when generating package cache fails.

  • Done
  • quality assurance status badge
Details
2 participants
  • Josselin Poiret
  • Ludovic Courtès
Owner
unassigned
Submitted by
Josselin Poiret
Severity
normal
J
J
Josselin Poiret wrote on 11 Jun 2022 18:30
(address . guix-patches@gnu.org)(name . Josselin Poiret)(address . dev@jpoiret.xyz)
20220611163031.23673-1-dev@jpoiret.xyz
* guix/channels.scm (package-cache-file): Add a throw handler around
the generate-package-cache call, and print backtrace in it.
---
guix/channels.scm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

Toggle diff (25 lines)
diff --git a/guix/channels.scm b/guix/channels.scm
index 20f347d34f..e3a4daf7b3 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -911,7 +911,17 @@ (define build
(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)
+ ;; Guile 1 prints the whole backtrace, and would need a
+ ;; fluid set for the backtrace procedure to work, so ignore.
+ (unless (string-prefix? "1" (version))
+ (backtrace)))))
(mkdir #$output))))
(gexp->derivation-in-inferior "guix-package-cache" build
--
2.36.1
J
J
Josselin Poiret wrote on 11 Jun 2022 18:59
[PATCH v2] channels: Print backtrace when generating package cache fails.
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 55911@debbugs.gnu.org)
20220611165938.25093-1-dev@jpoiret.xyz
* guix/channels.scm (package-cache-file): Add a throw handler around
the generate-package-cache call, and print backtrace in it.
---
IRC promptly pointed out that Guix has required Guile ver>=2 since way before
guix repl and guix pull were ever a thing, thus drop the Guile 1 compatibility
code. Enjoy this v2

Best,
Josselin
guix/channels.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

Toggle diff (22 lines)
diff --git a/guix/channels.scm b/guix/channels.scm
index 20f347d34f..fde425327d 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -911,7 +911,14 @@ (define build
(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
--
2.36.1
L
L
Ludovic Courtès wrote on 16 Jun 2022 11:10
Re: bug#55911: [PATCH] channels: Print backtrace when generating package cache fails.
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 55911-done@debbugs.gnu.org)
87sfo5m0rq.fsf_-_@gnu.org
Hi Josselin,

Josselin Poiret <dev@jpoiret.xyz> skribis:

Toggle quote (7 lines)
> * guix/channels.scm (package-cache-file): Add a throw handler around
> the generate-package-cache call, and print backtrace in it.
> ---
> IRC promptly pointed out that Guix has required Guile ver>=2 since way before
> guix repl and guix pull were ever a thing, thus drop the Guile 1 compatibility
> code. Enjoy this v2

That’s a good idea. Applied!

Thanks for the patch and for paying attention to compatibility!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 55911@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 55911
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch