GNU bug report logs - #74425
[PATCH] ui: Include channels in load path before searching for commands.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Carlo Zancanaro <carlo@HIDDEN>; Keywords: patch; merged with #74633; dated Mon, 18 Nov 2024 22:32:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Merged 74425 74633. Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 74425 <at> debbugs.gnu.org:


Received: (at 74425) by debbugs.gnu.org; 21 Nov 2024 23:25:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 21 18:25:27 2024
Received: from localhost ([127.0.0.1]:52120 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tEGYA-00050U-V9
	for submit <at> debbugs.gnu.org; Thu, 21 Nov 2024 18:25:27 -0500
Received: from voltorb.zancanaro.id.au ([45.77.50.64]:49958)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <carlo@HIDDEN>) id 1tEGY7-000506-N2
 for 74425 <at> debbugs.gnu.org; Thu, 21 Nov 2024 18:25:25 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=kcZcF91iKGwCmEQ
 cpnx4+XTBarzgFYCTit4ESJiyIZE=;
 h=date:references:in-reply-to:subject:
 cc:to:from; d=zancanaro.id.au; b=mDT8jwpLH/SCXhHOB+Vxg8cysnfIbNoOnUBPI
 kvVgE47l4W+j3IOfuFwdSFvQtRC0dY0Yk4eiZIKvcOafuRqW2McIpK3Qwzh6+Lhcn9dpKm
 L8+sD1zhd2egYvECOejMFKQLs98T+tW3kp/upyZgNrMqF+wcMR3DTveNItCCBxz4=
Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id faa7e0e7
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); 
 Thu, 21 Nov 2024 23:24:40 +0000 (UTC)
From: Carlo Zancanaro <carlo@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#74425] [PATCH] ui: Include channels in load path before
 searching for commands.
In-Reply-To: <87jzcwss1j.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Thu, 21 Nov 2024 13:14:00 +0100")
References: <eb0ba012b1cafc05b8438eb99a9c736237031242.1731968797.git.carlo@HIDDEN>
 <87jzcwss1j.fsf@HIDDEN>
Date: Fri, 22 Nov 2024 10:25:15 +1100
Message-ID: <87iksgxj8k.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 74425
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, 74425 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Thu, Nov 21 2024, Ludovic Court=C3=A8s wrote:
> I think you could do:
>
>   #:autoload (guix describe) (package-path-entries)
>
> instead of doing the trick above.

I tried that, and it breaks "guix pull" (as mentioned in the comment in
the code). I don't have the specific error easily accessible, but I
think it was "no code for module: (git)". I assume it was an issue with
how build-program in (build-self) puts things together, but I wasn't
able to investigate further than that.

>   1. The =E2=80=98%load-path=E2=80=99 and =E2=80=98%load-compiled-path=E2=
=80=99 modifications can now be
>      removed from (gnu packages), after checking that GUIX_PACKAGE_PATH
>      still takes precedence.

With this change, (extension-directories) does not include the paths in
GUIX_PACKAGE_PATH. Perhaps it should, but I wasn't sure given the
distinction between GUIX_PACKAGE_PATH and GUIX_EXTENSIONS_PATH.

Do we want to run commands from GUIX_PACKAGE_PATH? Or load packages from
GUIX_EXTENSIONS_PATH? At the moment I think the code says "no" to both.

My other concern with removing the code in (gnu packages) is that it may
break code that is using Guix as a library. That is, something like
this:

--8<---------------cut here---------------start------------->8---
guix shell guix guile -- guile -c '(use-modules (gnu packages)) (pk (find-p=
ackages-by-name "guile"))'
--8<---------------cut here---------------end--------------->8---

might not add the right things to the load path.

That said, the current patch will add duplicate entries to the load path
when using the Guix CLI, which also isn't good. Perhaps this needs to be
factored out into a single place where we can keep track of whether
we've already added to the load paths.

>   2. The performance impact of this change must be tested, in particular
>      the startup time of =E2=80=98guix=E2=80=99 commands since they=E2=80=
=99ll now be loading
>      (guix channels) & co. unconditionally.
>
>      One way to do that might be:
>
>        PROFILE=3D$(guix time-machine -q --url=3D/path/to/checkout)
>        guix shell time -- time $PROFILE/bin/guix build --help
>        strace -c $PROFILE/bin/guix build --help
>=20=20=20=20=20=20
> Could you give it a try?

Sure!

With the change in my patch, I'm seeing:

strace: number of calls and errors is roughly the same both with and
without my patch.

time: all the numbers look pretty similar with and without my patch.

I haven't done any statistical analysis of the various values recorded
by strace and time, but the numbers don't vary *too* much between runs,
so I'm fairly confident this isn't having too much of an effect.

I also tested leaving off the "-q" in the time machine call (so my other
channels were also included), but this didn't make any meaningful
difference to the numbers when running "guix build --help".

Carlo




Information forwarded to guix-patches@HIDDEN:
bug#74425; Package guix-patches. Full text available.

Message received at 74425 <at> debbugs.gnu.org:


Received: (at 74425) by debbugs.gnu.org; 21 Nov 2024 12:14:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 21 07:14:16 2024
Received: from localhost ([127.0.0.1]:49368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tE64d-0007XP-UA
	for submit <at> debbugs.gnu.org; Thu, 21 Nov 2024 07:14:16 -0500
Received: from eggs.gnu.org ([209.51.188.92]:48266)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1tE64b-0007XB-3G
 for 74425 <at> debbugs.gnu.org; Thu, 21 Nov 2024 07:14:14 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1tE64T-0008Bn-H2; Thu, 21 Nov 2024 07:14:05 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=7gXkbW91SghTUFyvriYx1dC7pj6vPwqxVCWLwZ1CE5k=; b=B2leUecz/tT+CxpkR9Pc
 6ndBDx8ZLt32IxwAeBYR6YJ0sFVGQjhi7zTu5FTDKai10zFLynSW/79wX4A1M5R1LrwtUUEWfMJ9U
 yvAaCALbiEyTvAkdh26nRGp/W4FuBdtQ9F7qi6X2uPMw/qJbw6nzIjYq0tONpo6/UDEAdFhtYuQTA
 d00ba+SPaZQch17LE7A1Wv074sWVi8N4g3n9AXeaL90t3QbEVjRnXR1ibrl4mUfalj6NCxd9yVcn5
 fl1zBkaHXfa5DHZSVyJ16Aaecf2k7NLR6eIPEhFT0GcyTXFnikudktb0RKJl3TC5A/gNSDu7Q0z6e
 bf4cy/0X1oZCJA==;
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Carlo Zancanaro <carlo@HIDDEN>
Subject: Re: [bug#74425] [PATCH] ui: Include channels in load path before
 searching for commands.
In-Reply-To: <eb0ba012b1cafc05b8438eb99a9c736237031242.1731968797.git.carlo@HIDDEN>
 (Carlo Zancanaro's message of "Tue, 19 Nov 2024 09:26:37 +1100")
References: <eb0ba012b1cafc05b8438eb99a9c736237031242.1731968797.git.carlo@HIDDEN>
Date: Thu, 21 Nov 2024 13:14:00 +0100
Message-ID: <87jzcwss1j.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 74425
Cc: Josselin Poiret <dev@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, 74425 <at> debbugs.gnu.org,
 Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello,

Carlo Zancanaro <carlo@HIDDEN> skribis:

> * guix/ui.scm (extension-directories): Add channel directories to load pa=
th,
> compiled load path, and returned list of directories.
>
> Co-authored-by: Ludovic Court=C3=A8s <ludo@HIDDEN>
> Change-Id: I3063cbf7164a065b2c6c2a5c6473df79ce8cbe9b

Nice, thanks for looking into it!

>  (define (extension-directories)
>    "Return the list of directories containing Guix extensions."
> -  (filter file-exists?
> -          (parse-path
> -           (getenv "GUIX_EXTENSIONS_PATH"))))
> +  (define package-path-entries
> +    ;; We need to resolve this lazily, because even using an #:autoload =
is too
> +    ;; much and breaks compilation during "guix pull".
> +    (module-ref (resolve-module `(guix describe))
> +                (symbol-append 'package-path-entries)))
> +  (let ((scm-path go-path (package-path-entries)))
> +    (set! %load-path (append %load-path scm-path))
> +    (set! %load-compiled-path (append %load-compiled-path go-path))
> +    (filter file-exists?
> +            (parse-path (getenv "GUIX_EXTENSIONS_PATH") scm-path))))

I think you could do:

  #:autoload (guix describe) (package-path-entries)

instead of doing the trick above.

Two things:

  1. The =E2=80=98%load-path=E2=80=99 and =E2=80=98%load-compiled-path=E2=
=80=99 modifications can now be
     removed from (gnu packages), after checking that GUIX_PACKAGE_PATH
     still takes precedence.

  2. The performance impact of this change must be tested, in particular
     the startup time of =E2=80=98guix=E2=80=99 commands since they=E2=80=
=99ll now be loading
     (guix channels) & co. unconditionally.

     One way to do that might be:

       PROFILE=3D$(guix time-machine -q --url=3D/path/to/checkout)
       guix shell time -- time $PROFILE/bin/guix build --help
       strace -c $PROFILE/bin/guix build --help
=20=20=20=20=20
Could you give it a try?

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#74425; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Nov 2024 22:31:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 18 17:31:51 2024
Received: from localhost ([127.0.0.1]:39521 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tDAHf-0006Yv-FN
	for submit <at> debbugs.gnu.org; Mon, 18 Nov 2024 17:31:51 -0500
Received: from lists.gnu.org ([209.51.188.17]:59936)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <carlo@HIDDEN>) id 1tDAHd-0006Yk-2O
 for submit <at> debbugs.gnu.org; Mon, 18 Nov 2024 17:31:49 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <carlo@HIDDEN>)
 id 1tDAHY-0000Bh-Lh
 for guix-patches@HIDDEN; Mon, 18 Nov 2024 17:31:46 -0500
Received: from voltorb.zancanaro.id.au ([45.77.50.64])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <carlo@HIDDEN>)
 id 1tDAHV-0000oD-JW; Mon, 18 Nov 2024 17:31:44 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=k1; bh=Vhrp4Krewb2kkOi
 42o0mrt2OOUKtcqejlGmj7U1iq1o=; h=date:subject:cc:to:from;
 d=zancanaro.id.au; b=GWwEdzRzOdFvMTwCJVSXDk1HATODB6IW9sILlx2OubQXdoUpr
 zaDAm5osVECqngy357w1DXE7NUk67kNLWNZq3OvIQRKvIBsJ2OMdz1T94oI5piB9DCdjkT
 e/6IMqrAK85PXiViivunrdjj+k9COZSJiy11ZInO6cm7+dOTCWpk=
Received: by voltorb.zancanaro.id.au (OpenSMTPD) with ESMTPSA id bf58f6aa
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); 
 Mon, 18 Nov 2024 22:30:49 +0000 (UTC)
From: Carlo Zancanaro <carlo@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] ui: Include channels in load path before searching for
 commands.
Date: Tue, 19 Nov 2024 09:26:37 +1100
Message-ID: <eb0ba012b1cafc05b8438eb99a9c736237031242.1731968797.git.carlo@HIDDEN>
X-Mailer: git-send-email 2.46.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=45.77.50.64; envelope-from=carlo@HIDDEN;
 helo=voltorb.zancanaro.id.au
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

* guix/ui.scm (extension-directories): Add channel directories to load path,
compiled load path, and returned list of directories.

Co-authored-by: Ludovic Courtès <ludo@HIDDEN>
Change-Id: I3063cbf7164a065b2c6c2a5c6473df79ce8cbe9b
---

This patch allows extensions in channels to be found by the Guix
CLI. Most notably, this means that a script can define commands by
defining an appropriate (guix scripts X) module, with a guix-X
function.

This is a slight modification to a diff that Ludovic sent through IRC.

I've tested that it works when I use "guix time-machine". Guix is able
to find a command that I define in a channel.

I haven't specifically tested that it finds commands when run through
"guix pull", but I have tested that this change does not break "guix
pull".

 guix/ui.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 447550635c..a702b6f3f8 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
 ;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
 ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@HIDDEN>
+;;; Copyright © 2024 Carlo Zancanaro <carlo@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -73,6 +74,7 @@ (define-module (guix ui)                       ;import in user interfaces only
   #:use-module (srfi srfi-31)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-71)
   #:autoload   (ice-9 ftw)  (scandir)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -2192,9 +2194,16 @@ (define* (command-files #:optional directory)
 
 (define (extension-directories)
   "Return the list of directories containing Guix extensions."
-  (filter file-exists?
-          (parse-path
-           (getenv "GUIX_EXTENSIONS_PATH"))))
+  (define package-path-entries
+    ;; We need to resolve this lazily, because even using an #:autoload is too
+    ;; much and breaks compilation during "guix pull".
+    (module-ref (resolve-module `(guix describe))
+                (symbol-append 'package-path-entries)))
+  (let ((scm-path go-path (package-path-entries)))
+    (set! %load-path (append %load-path scm-path))
+    (set! %load-compiled-path (append %load-compiled-path go-path))
+    (filter file-exists?
+            (parse-path (getenv "GUIX_EXTENSIONS_PATH") scm-path))))
 
 (define (commands)
   "Return the list of commands, alphabetically sorted."

base-commit: 23cbbe6860782c5d4a0ba599ea1cda0642e91661
-- 
2.46.0





Acknowledgement sent to Carlo Zancanaro <carlo@HIDDEN>:
New bug report received and forwarded. Copy sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#74425; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

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