[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#42688: Running a script with `guix repl` doesn't "see" additional ch
bug#42688: Running a script with `guix repl` doesn't "see" additional channels using (%package-module-path)
Thu, 17 Sep 2020 17:31:05 +0200
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Leo Prikler <email@example.com> skribis:
> I've finally figured out, what causes this issue.
> Guix repl uses the following code to call scripts:
> (unless (null? script)
> ;; Run script
> (lambda ()
> (set-program-arguments script)
> (load-in-vicinity "." (car script)))))
> But `guix describe` (which is used to initialize %package-module-path)
> has the following:
> (define current-profile
> (mlambda ()
> "Return the profile (created by 'guix pull') the calling process
> lives in,
> or #f if this is not applicable."
> (match (command-line)
> ((program . _)
> (and (string-suffix? "/bin/guix" program)
> (define current-profile-entries [...])
> (define current-channel-entries [...])
> (define package-path-entries [...])
> Each of these procedures depends on the previous, building up a chain
> that fails exactly in the case where we (set-program-arguments [...])
> with a script other than the current channel's guix (which is probably
> the way you'd want to use `guix repl`).
> There are some ways of resolving this. One would be to access earlier
> versions of "command-line" – it does resolve to a fluid, but that fluid
> itself is not exposed to Guile. Perhaps there might be some FFI magic
> to access it.
‘scm_program_arguments_fluid’ is marked as SCM_INTERNAL, so it’s really
However, perhaps we could save the initial value of (program-arguments)
in (guix ui) and use that in (guix describe)?
> On the other hand, we could patch `guix repl` to initialize %package-
> module-path earlier (still leaving `guix describe` broken) or somehow
> try to work around that issue in `guix describe`.
Initializing (%package-module-path) earlier sounds like a good idea too,
maybe like this:
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 7d4e474e92..b672489ed6 100644
@@ -22,6 +22,7 @@
#:use-module (guix ui)
#:use-module (guix scripts)
#:use-module (guix repl)
+ #:autoload (gnu packages) (%package-module-path)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
@@ -173,6 +174,10 @@ call THUNK."
(unless (null? script)
+ ;; Before running SCRIPT, initialize %PACKAGE-MODULE-PATH so that it
+ ;; contains the user's channels (the statement triggers an autoload).
;; Run script