Ludovic Courtès <ludo@gnu.org> skribis:
Toggle quote (10 lines)
> Commit 6f9d844d2ece7b369d17bbe678978462425f869c led to a regression:
> when a ‘luks-device-mapping’ mapped device is opened from a Shepherd
> service (for instance a ‘device-mapping-XXX’ service created by
> ‘device-mapping-service-type’ because, say, /home is a separate LUKS
> partition), said service fails to start with:
>
> Unbound variable: bytevector?
>
> This is the ‘bytevector?’ referred to in ‘open-luks-device’.
This is a situation with a non-top-level ‘use-modules’.
The problem can be illustrated like this:
Toggle snippet (38 lines)
$ cat ~/src/guile-debugging/non-top-level-use-modules.scm
;; (define-module (xxxx))
(define (foo x)
(use-modules (rnrs bytevectors)) ;bad!!
(bytevector? x))
;; (pk '-> (foo (call-with-input-string "#vu8(1 2 3)" read)))
(pk 'foo foo)
$ guild compile -O1 ~/src/guile-debugging/non-top-level-use-modules.scm
/home/ludo/src/guile-debugging/non-top-level-use-modules.scm:3:3: warning: possibly unbound variable `bytevector?'
wrote `/home/ludo/.cache/guile/ccache/3.0-LE-8-4.7/home/ludo/src/guile-debugging/non-top-level-use-modules.scm.go'
$ guile
GNU Guile 3.0.99-git
Copyright (C) 1995-2024 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,m(sdf)
scheme@(sdf)> ,use(guile)
scheme@(sdf)> (load-compiled "/home/ludo/.cache/guile/ccache/3.0-LE-8-4.7/home/ludo/src/guile-debugging/non-top-level-use-modules.scm.go")
;;; (foo #<procedure foo (x)>)
$1 = #<procedure foo (x)>
scheme@(sdf)> ,m(guile-user)
scheme@(guile-user)> ($1 123)
;;; <stdin>:7:1: warning: possibly unbound variable `$1'
ice-9/boot-9.scm:1676:22: In procedure raise-exception:
Unbound variable: bytevector?
Entering a new prompt. Type `,bt' for a backtrace or `,q' to contin
‘use-modules’, when used this way, loads the specified modules in
(current-module) at that point (at run time). If you change what the
current module is, as I did above, then it breaks.
Ludo’.