Subject: bug#78598: guix build fails when debugging is enabled with --debug

From: "Owen T. Heisler" <[email-masked]>
Date: Mon, 26 May 2025 17:07:25 -0500

Hello,

Most builds fail when debugging is enabled by the calling script. This
seems to be related to displaying build progress, so it will *not* fail
if the requirements are already available in the store.

```console
$ guix describe -f channels-sans-intro
(list (channel
        (name 'guix)
        (url "https://git.guix.gnu.org/guix.git")
        (branch "master")
        (commit
          "36bd8e176c1befcc4d959fb1662d8c3e3d0e2474")))

$ guix gc -D /gnu/store/*-hello-*

$ guix build --debug=1 --file=test.scm --no-substitutes
The following derivations will be built:
  /gnu/store/5rdaqszqa2q3pzz43afqw62qniq8xgkd-profile.drv
  /gnu/store/14xgk2ym3rls18cw02dhzm7gwz9m834h-system.drv
The following profile hook will be built:
   /gnu/store/fyh5hhk7bf9bywzyda7a7r240lv5zmkd-manual-database.drv
building path(s)
`/gnu/store/95vcxzqwvnzzn2mlxsn56yjkabnlv1mm-manual-database'
|   @ build-started
/gnu/store/fyh5hhk7bf9bywzyda7a7r240lv5zmkd-manual-database.drv -
x86_64-linux
/var/log/guix/drvs/fy//h5hhk7bf9bywzyda7a7r240lv5zmkd-manual-database.drv.gz
3774190
Creating manual page database...
Backtrace:
In ice-9/boot-9.scm:
    724:2 19 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8 18 (_ #(#(#<directory (guile-user) 7fa097acfc80>)))
In guix/ui.scm:
   2352:7 17 (run-guix . _)
  2315:10 16 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10 15 (with-exception-handler _ _ #:unwind? _ # _)
In guix/status.scm:
    839:4 14 (call-with-status-report _ _)
In ice-9/boot-9.scm:
  1752:10 13 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
   690:37 12 (thunk)
   1331:8 11 (call-with-build-handler _ _)
   1331:8 10 (call-with-build-handler #<procedure 7fa0922c4a80 at g…> …)
In guix/scripts/build.scm:
   915:27  9 (_)
In guix/store.scm:
  1450:15  8 (_ #<store-connection 256.99 7fa0922fc7d0> _ _)
   773:14  7 (process-stderr _ _)
In unknown file:
           6 (display "@ build-log 3774190 45\n\r[  1/ 64] building…" …)
In guix/status.scm:
   779:20  5 (write! _ _ _)
In srfi/srfi-1.scm:
   460:18  4 (fold #<procedure 7fa09231be20 at guix/status.scm:668:…> …)
In guix/status.scm:
   669:15  3 (_ (build-log 3774190 "\r[  1/ 64] building list of …") #)
   180:23  2 (update-build #<<build-status> building: () downloadin…> …)
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:
In procedure struct-vtable: Wrong type argument in position 1 (expecting
struct): #f
```

Using the following `test.scm`:

```scm
(define-module (test)
  #:use-module (gnu packages base)
  #:use-module (gnu bootloader)
  #:use-module (gnu bootloader grub)
  #:use-module (gnu system)
  #:use-module (gnu system file-systems))

(operating-system
 (bootloader (bootloader-configuration
              (bootloader grub-bootloader)))
 (file-systems (cons (file-system
                      (device "/dev/vda1")
                      (mount-point "/")
                      (type "ext4"))
                     %base-file-systems))
 (host-name "test")
 (packages (append (list hello) %base-packages)))
```

Thanks,
Owen