GNU bug report logs - #61574
[PATCH v2] scripts: repl: Extend REPL %load-path with all channels.

Previous Next

Package: guix;

Reported by: Simon Tournier <zimon.toutoune <at> gmail.com>

Date: Fri, 17 Feb 2023 14:57:01 UTC

Severity: normal

Merged with 61343

To reply to this bug, email your comments to 61574 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#61574; Package guix. (Fri, 17 Feb 2023 14:57:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Tournier <zimon.toutoune <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Fri, 17 Feb 2023 14:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Josselin Poiret via Bug reports for GNU Guix <bug-guix <at> gnu.org>,
 Simon Tournier <zimon.toutoune <at> gmail.com>,
 宋文武 <iyzsong <at> envs.net>,
 61343 <at> debbugs.gnu.org
Cc: Josselin Poiret <dev <at> jpoiret.xyz>
Subject: [PATCH v2] scripts: repl: Extend REPL %load-path with all channels.
Date: Fri, 17 Feb 2023 15:56:27 +0100
Fixes <https://bugs.gnu.org/61343>.
Reported by 宋文武 <iyzsong <at> envs.net>.

* guix/scripts/repl.scm (define-command): Before starting the REPL,
run (current-profile) which makes available all channels.
---

Hi,

Instead I am proposing this, it avoids to load all the module.

For testing, once applied to some Guix checkout, just run:

$ ./pre-inst-env guix pull --disable-authentication -C /tmp/channels.scm -p /tmp/new
$ echo '(use-modules (rde features))' | /tmp/new/bin/guix repl /dev/stdin

where /tmp/channels.scm reads,

(list
 (channel
  (name 'rde)
  (url "https://git.sr.ht/~abcdw/rde")
  (introduction
   (make-channel-introduction
    "257cebd587b66e4d865b3537a9a88cccd7107c95"
    (openpgp-fingerprint
     "2841 9AC6 5038 7440 C7E9  2FFA 2208 D209 58C1 DEB0"))))
 (channel
  (name 'guix)
  (url "/home/simon/src/guix/guix")))

tweaking the path to your Guix checkout.

Cheers,
simon


 guix/scripts/repl.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 787c63d48e..fc55d79c41 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -211,6 +211,7 @@ (define script
               ((guile)
                (save-module-excursion
                 (lambda ()
+                  (current-profile) ;Run (%package-module-path) as explained above.
                   (set-user-module)
                   ;; Do not exit repl on SIGINT.
                   ((@@ (ice-9 top-repl) call-with-sigint)

base-commit: cb45e9d0dc6cbe6f69a858f71252411610b4ce82
-- 
2.38.1





Merged 61343 61574. Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 17 Feb 2023 15:11:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#61574; Package guix. (Mon, 27 Feb 2023 14:02:03 GMT) Full text and rfc822 format available.

Message #10 received at 61574-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon Tournier <zimon.toutoune <at> gmail.com>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, 61574-done <at> debbugs.gnu.org,
 61343-done <at> debbugs.gnu.org, iyzsong <at> envs.net
Subject: Re: bug#61574: [PATCH v2] scripts: repl: Extend REPL %load-path
 with all channels.
Date: Mon, 27 Feb 2023 15:01:11 +0100
Hi Simon,

Simon Tournier <zimon.toutoune <at> gmail.com> skribis:

> Fixes <https://bugs.gnu.org/61343>.
> Reported by 宋文武 <iyzsong <at> envs.net>.
>
> * guix/scripts/repl.scm (define-command): Before starting the REPL,
> run (current-profile) which makes available all channels.

[...]

> +++ b/guix/scripts/repl.scm
> @@ -211,6 +211,7 @@ (define script
>                ((guile)
>                 (save-module-excursion
>                  (lambda ()
> +                  (current-profile) ;Run (%package-module-path) as explained above.

I tweaked the comment :-) and applied.

Thanks!

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#61574; Package guix. (Thu, 02 Mar 2023 13:45:02 GMT) Full text and rfc822 format available.

Message #13 received at 61574-done <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>, Simon Tournier
 <zimon.toutoune <at> gmail.com>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, 61343-done <at> debbugs.gnu.org,
 61574-done <at> debbugs.gnu.org, iyzsong <at> envs.net
Subject: Re: bug#61343: bug#61574: [PATCH v2] scripts: repl: Extend REPL
 %load-path with all channels.
Date: Thu, 02 Mar 2023 17:44:20 +0400
[Message part 1 (text/plain, inline)]
On 2023-02-27 15:01, Ludovic Courtès wrote:

> Hi Simon,
>
> Simon Tournier <zimon.toutoune <at> gmail.com> skribis:
>
>> Fixes <https://bugs.gnu.org/61343>.
>> Reported by 宋文武 <iyzsong <at> envs.net>.
>>
>> * guix/scripts/repl.scm (define-command): Before starting the REPL,
>> run (current-profile) which makes available all channels.
>
> [...]
>
>> +++ b/guix/scripts/repl.scm
>> @@ -211,6 +211,7 @@ (define script
>>                ((guile)
>>                 (save-module-excursion
>>                  (lambda ()
>> +                  (current-profile) ;Run (%package-module-path) as explained above.
>
> I tweaked the comment :-) and applied.
>
> Thanks!

Hi Simon and Ludo!

Thank you for the patch, I also faced this problem and it seems this
change doesn't fix it.

echo '(use-modules (rde features))' | guix repl /dev/stdin

still fails on a7763e067d86908210758aab80d33e4f8b815b1c.

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#61574; Package guix. (Thu, 02 Mar 2023 19:49:02 GMT) Full text and rfc822 format available.

Message #16 received at 61574 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Andrew Tropin <andrew <at> trop.in>, Ludovic Courtès
 <ludo <at> gnu.org>
Cc: 61574 <at> debbugs.gnu.org, Josselin Poiret <dev <at> jpoiret.xyz>,
 61343 <at> debbugs.gnu.org, iyzsong <at> envs.net
Subject: Re: bug#61574: bug#61343: bug#61574: [PATCH v2] scripts: repl:
 Extend REPL %load-path with all channels.
Date: Thu, 02 Mar 2023 20:48:07 +0100
Hi,

I reopen the bug.

On jeu., 02 mars 2023 at 17:44, Andrew Tropin <andrew <at> trop.in> wrote:

> Thank you for the patch, I also faced this problem and it seems this
> change doesn't fix it.

Indeed.  I have no clue what I messed up.  Since I removed the Git
worktree, I am not able to investigate the root of my mistake.  I
remember running with ’guix repl -q’ for avoiding spurious ~/.guile
configuration and I remember running “./pre-inst-env guix pull -p
/tmp/new” and checking.  Hum?!  Anyway!

My apologies.

Back to the issue:

   1. The patch does not tweak ’guix repl script.scm’ but only the
      interactive part – which also has the issue, I guess.

   2. The culprit seems (current-profile) which does not correctly load
      %package-module-path as the comment is suggesting,

            ;;                           This in turn ensures that
            ;; (%package-module-path) will contain entries for the channels
            ;; available in the current profile.


Adding (gnu packages) as Josselin suggested but commenting
(current-profile) make channels available both for scripts and
interactive.  For instance this patch works, which means something is
buggy somewhere.

--8<---------------cut here---------------start------------->8---
1 file changed, 5 insertions(+), 2 deletions(-)
guix/scripts/repl.scm | 7 +++++--

modified   guix/scripts/repl.scm
@@ -22,6 +22,7 @@ (define-module (guix scripts repl)
   #:use-module (guix ui)
   #:use-module (guix scripts)
   #:use-module (guix repl)
+  #:use-module (gnu packages)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-37)
@@ -193,7 +194,8 @@ (define script
          ;; 'set-program-arguments'.  This in turn ensures that
          ;; (%package-module-path) will contain entries for the channels
          ;; available in the current profile.
-         (current-profile)
+         (pk 'script)
+                                        ;(current-profile)
 
          (set-program-arguments script)
          (set-user-module)
@@ -211,7 +213,8 @@ (define script
               ((guile)
                (save-module-excursion
                 (lambda ()
-                  (current-profile) ;Run (%package-module-path) as explained above.
+                  (pk 'no-script)
+                                        ;(current-profile) ;Run (%package-module-path) as explained above.
                   (set-user-module)
                   ;; Do not exit repl on SIGINT.
                   ((@@ (ice-9 top-repl) call-with-sigint)
--8<---------------cut here---------------end--------------->8---


Well, I have tried to debug by adding ’pk’ around but I often get error
when “Computing Guix derivation”.  Well, the test-error is a long
process here. :-)

As discussed in #42688 [1], instead of
1b179d7876f19f04009a2f9e248ac10711f4c660, the plain call to
(%package-module-path) – instead of (current-profile) – fixes the issue.

This patch works and avoids the full load of (gnu packages), I guess
twice. :-)

--8<---------------cut here---------------start------------->8---
1 file changed, 3 insertions(+), 3 deletions(-)
guix/scripts/repl.scm | 6 +++---

modified   guix/scripts/repl.scm
@@ -27,7 +27,7 @@ (define-module (guix scripts repl)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:use-module (rnrs bytevectors)
-  #:autoload   (guix describe) (current-profile)
+  #:autoload   (gnu packages) (%package-module-path)
   #:autoload   (system repl repl) (start-repl)
   #:autoload   (system repl server)
                   (make-tcp-server-socket make-unix-domain-server-socket)
@@ -193,7 +193,7 @@ (define script
          ;; 'set-program-arguments'.  This in turn ensures that
          ;; (%package-module-path) will contain entries for the channels
          ;; available in the current profile.
-         (current-profile)
+         (%package-module-path)
 
          (set-program-arguments script)
          (set-user-module)
@@ -211,7 +211,7 @@ (define script
               ((guile)
                (save-module-excursion
                 (lambda ()
-                  (current-profile) ;Run (%package-module-path) as explained above.
+                  (%package-module-path)
                   (set-user-module)
                   ;; Do not exit repl on SIGINT.
                   ((@@ (ice-9 top-repl) call-with-sigint)
--8<---------------cut here---------------end--------------->8---


1: <https://issues.guix.gnu.org/issue/42688>


Cheers,
simon




Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 02 Mar 2023 19:49:03 GMT) Full text and rfc822 format available.

Removed tag(s) patch. Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 02 Mar 2023 19:49:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#61574; Package guix. (Fri, 03 Mar 2023 11:15:02 GMT) Full text and rfc822 format available.

Message #23 received at 61574 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Simon Tournier <zimon.toutoune <at> gmail.com>
Cc: 61574 <at> debbugs.gnu.org, Josselin Poiret <dev <at> jpoiret.xyz>,
 61343 <at> debbugs.gnu.org, iyzsong <at> envs.net, Andrew Tropin <andrew <at> trop.in>
Subject: Re: bug#61574: bug#61343: bug#61574: [PATCH v2] scripts: repl:
 Extend REPL %load-path with all channels.
Date: Fri, 03 Mar 2023 12:14:00 +0100
Simon Tournier <zimon.toutoune <at> gmail.com> skribis:

> 1 file changed, 3 insertions(+), 3 deletions(-)
> guix/scripts/repl.scm | 6 +++---
>
> modified   guix/scripts/repl.scm
> @@ -27,7 +27,7 @@ (define-module (guix scripts repl)
>    #:use-module (srfi srfi-37)
>    #:use-module (ice-9 match)
>    #:use-module (rnrs bytevectors)
> -  #:autoload   (guix describe) (current-profile)
> +  #:autoload   (gnu packages) (%package-module-path)
>    #:autoload   (system repl repl) (start-repl)
>    #:autoload   (system repl server)
>                    (make-tcp-server-socket make-unix-domain-server-socket)
> @@ -193,7 +193,7 @@ (define script
>           ;; 'set-program-arguments'.  This in turn ensures that
>           ;; (%package-module-path) will contain entries for the channels
>           ;; available in the current profile.
> -         (current-profile)
> +         (%package-module-path)

Per the comment right above, this change would break the program name
memoization, wouldn’t it?

Ludo’.




This bug report was last modified 2 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.