summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-12-23 15:51:17 +0100
committerRutherther <rutherther@ditigal.xyz>2026-01-04 12:46:56 +0100
commitd2a93e61138f65c48dc97478ec54bee254e9853e (patch)
tree740cb63d17f3729e4c020e0d3216223491b7fa63
parent7c3185afcbecb153cb96c4c8dea046f633e9f04d (diff)
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 <thijs@ouroboros.rocks> Reported-by: Tomas Volf <~@wolfsden.cz> Change-Id: I430dd6e6e2bd9e423d47dbb310d4553f6cd7f19b Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #5074 Signed-off-by: Rutherther <rutherther@ditigal.xyz>
-rw-r--r--guix/describe.scm22
1 files 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 <ludo@gnu.org>
+;;; Copyright © 2018-2021, 2024-2025 Ludovic Courtès <ludo@gnu.org>
;;;
;;; 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)