Subject: bug#52449: “guix shell” in Guix checkout prints backtrace

From: Ricardo Wurmus <[email-masked]>
Date: Sun, 12 Dec 2021 12:30:54 +0000

When running “guix shell” in a source checkout of Guix prints a
backtrace:

--8<---------------cut here---------------start------------->8---
$ guix shell
guix shell: loading environment from '/home/rekado/dev/gx/utf/guix.scm'...
hint: Consider passing the `--check' option once to make sure your shell does not clobber environment variables.

Backtrace:
          14 (primitive-load "/home/rekado/.config/guix/current/bin/guix")
In guix/ui.scm:
   2206:7 13 (run-guix . _)
  2169:10 12 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10 11 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
  1752:10 10 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In guix/store.scm:
   658:37  9 (thunk)
   1320:8  8 (call-with-build-handler #<procedure 7fa80677a240 at guix/ui.scm:1156:2 (continue store things mode)> _)
In guix/status.scm:
    802:4  7 (call-with-status-report _ _)
In guix/scripts/environment.scm:
    317:4  6 (_)
In srfi/srfi-1.scm:
   673:15  5 (append-map #<procedure 7fa806784c00 at guix/scripts/environment.scm:317:16 (expr)> ((gc-root . "/home/rekado/.cache/guix/profiles/repcfratbkwoufn7si47j5owec2csk4wg7o5…") …))
   586:29  4 (map1 ((gc-root . "/home/rekado/.cache/guix/profiles/repcfratbkwoufn7si47j5owec2csk4wg7o5ps5qcoyl22ff5kcq") (load package "/home/rekado/dev/gx/utf/guix.scm") (# . #t) # # …))
   586:17  3 (map1 ((load package "/home/rekado/dev/gx/utf/guix.scm") (ad-hoc? . #t) (system . "x86_64-linux") (substitutes? . #t) (offload? . #t) (graft? . #t) (# . #t) (# . #t) # # #))
In guix/scripts/environment.scm:
    303:4  2 (packages->outputs _ _)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" #<unspecified>)'.
$ --8<---------------cut here---------------end--------------->8---

That’s probably because “guix.scm” doesn’t return a package.  It’s not
an environment definition, so it’s expected that this doesn’t work.  But
this backtrace is pretty ugly.  It would be nicer to bail if guix.scm
doesn’t evaluate to a package value.

-- 
Ricardo