From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wGJlMTKDY18UNgAA0tVLHw (envelope-from ) for ; Thu, 17 Sep 2020 15:39:30 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YLVdLTKDY19NaAAA1q6Kng (envelope-from ) for ; Thu, 17 Sep 2020 15:39:30 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 45DE39400D3 for ; Thu, 17 Sep 2020 15:39:30 +0000 (UTC) Received: from localhost ([::1]:46846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIw0P-0003zQ-4t for larch@yhetil.org; Thu, 17 Sep 2020 11:39:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIvtC-0005SN-9t for bug-guix@gnu.org; Thu, 17 Sep 2020 11:32:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIvtB-0007Bp-R8 for bug-guix@gnu.org; Thu, 17 Sep 2020 11:32:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kIvtB-00083i-ND for bug-guix@gnu.org; Thu, 17 Sep 2020 11:32:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#42688: Running a script with `guix repl` doesn't "see" additional channels using (%package-module-path) Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 17 Sep 2020 15:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42688 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Received: via spool by 42688-submit@debbugs.gnu.org id=B42688.160035668429167 (code B ref 42688); Thu, 17 Sep 2020 15:32:01 +0000 Received: (at 42688) by debbugs.gnu.org; 17 Sep 2020 15:31:24 +0000 Received: from localhost ([127.0.0.1]:38676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIvsZ-0007a4-Ud for submit@debbugs.gnu.org; Thu, 17 Sep 2020 11:31:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kIvsS-0007Py-Kh for 42688@debbugs.gnu.org; Thu, 17 Sep 2020 11:31:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38752) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIvsL-000742-DS; Thu, 17 Sep 2020 11:31:09 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=55990 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kIvsK-0002bM-8t; Thu, 17 Sep 2020 11:31:08 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200803043331.78b20336@runbox.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Jour du =?UTF-8?Q?G=C3=A9nie?= de =?UTF-8?Q?l'Ann=C3=A9e?= 228 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 17 Sep 2020 17:31:05 +0200 In-Reply-To: (Leo Prikler's message of "Wed, 16 Sep 2020 17:16:52 +0200") Message-ID: <874knws9mu.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 42688@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: G+6TZyuZks2y --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Leo, Leo Prikler skribis: > I've finally figured out, what causes this issue. > > Guix repl uses the following code to call scripts: > ``` > (unless (null? script) > ;; Run script > (save-module-excursion > (lambda () > (set-program-arguments script) > (set-user-module) > (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`).=20=20 Good catch! > There are some ways of resolving this. One would be to access earlier > versions of "command-line" =E2=80=93 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. =E2=80=98scm_program_arguments_fluid=E2=80=99 is marked as SCM_INTERNAL, so= it=E2=80=99s really inaccessible. 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: --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm index 7d4e474e92..b672489ed6 100644 --- a/guix/scripts/repl.scm +++ b/guix/scripts/repl.scm @@ -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." (with-error-handling (unless (null? script) + ;; Before running SCRIPT, initialize %PACKAGE-MODULE-PATH so that it + ;; contains the user's channels (the statement triggers an autoload). + (%package-module-path) + ;; Run script (save-module-excursion (lambda () --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ? Thanks! Ludo=E2=80=99. --=-=-=--