guix_mirror_bot pushed a commit to branch version-1.5.0
in repository guix.

commit d2a93e61138f65c48dc97478ec54bee254e9853e
Author: Ludovic Courtès <[email protected]>
AuthorDate: Tue Dec 23 15:51:17 2025 +0100

    describe: Add channels to the load path right after ‘guix’.
    
    * 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 <[email protected]>
    Reported-by: Tomas Volf <[email protected]>
    Change-Id: I430dd6e6e2bd9e423d47dbb310d4553f6cd7f19b
    Signed-off-by: Ludovic Courtès <[email protected]>
    Merges: #5074
    Signed-off-by: Rutherther <[email protected]>
---
 guix/describe.scm | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/guix/describe.scm b/guix/describe.scm
index 819f0fef74..c5bbb951a7 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 <[email protected]>
+;;; Copyright © 2018-2021, 2024-2025 Ludovic Courtès <[email protected]>
 ;;;
 ;;; 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: <https://codeberg.org/guix/guix/issues/4819>.
     (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)

Reply via email to