From d2a93e61138f65c48dc97478ec54bee254e9853e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 23 Dec 2025 15:51:17 +0100 Subject: [PATCH] =?UTF-8?q?describe:=20Add=20channels=20to=20the=20load=20?= =?UTF-8?q?path=20right=20after=20=E2=80=98guix=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/describe.scm (append-channels-to-load-path!): Add ‘channels-scm’ and ‘channels-go’ in second position. Fixes: guix/guix#4819 Fixes: https://issues.guix.gnu.org/74396 Reported-by: Thijs Paelman Reported-by: Tomas Volf <~@wolfsden.cz> Change-Id: I430dd6e6e2bd9e423d47dbb310d4553f6cd7f19b Signed-off-by: Ludovic Courtès Merges: #5074 Signed-off-by: Rutherther --- guix/describe.scm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/guix/describe.scm b/guix/describe.scm index 819f0fef748..c5bbb951a7f 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018-2021, 2024 Ludovic Courtès +;;; Copyright © 2018-2021, 2024-2025 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -193,16 +193,28 @@ when applicable." (current-channel-entries)))) (define (append-channels-to-load-path!) - "Automatically add channels to Guile's search path. Channels are added to the -end of the path so they don't override Guix' own modules. + "Add channels to Guile's search path. Channels are added right after the +'guix' channel so they don't override Guix' own modules, but before entries +coming from $GUILE_LOAD_PATH. This procedure ensures that channels are only added to the search path once even if it is called multiple times." (let ((channels-scm channels-go (package-path-entries))) + ;; The 'guix' binary, both from 'guix pull' and from the 'guix' package, + ;; adds the 'guix' channel as the first element of the search path. Thus, + ;; append CHANNELS-SCM and CHANNELS-GO right after that. + ;; + ;; Adding channels to the back of the search path, and thus after anything + ;; that happens to be in $GUILE_LOAD_PATH, could lead to loading the wrong + ;; package modules: . (set! %load-path - (append %load-path channels-scm)) + (match %load-path + ((head . tail) + (append (list head) channels-scm tail)))) (set! %load-compiled-path - (append %load-compiled-path channels-go))) + (match %load-compiled-path + ((head . tail) + (append (list head) channels-go tail))))) (set! append-channels-to-load-path! (lambda () #t))) (define (package-channels package)