From bf1f18130f2b54a2bd1e8a57d6dae3a611573ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 17 Aug 2026 15:32:11 +0200 Subject: ui: Fix not finding compiled files when loading extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Guix command load machinery was using 'load' with an absolute file name which meant that the compiled file would be searched under directories from 'GUILE_LOAD_COMPILED_PATH' using the absolute paths. For example: Given 'GUILE_LOAD_COMPILED_PATH=/path/to/site-ccache' '//guix/extensions/foo.scm' would be searched under '/path/to/site-ccache///guix/extensions/foo.scm', rather than ''/path/to/site-ccache/guix/extensions/foo.scm'. * guix/ui.scm (run-guix-command): Use 'resolve-interface' rather than 'load' with an absolute path to ensure that the compiled files can be found 'GUILE_LOAD_COMPILED_PATH' without the absolute path appended. (run-guix): Augment '%load-path' with GUIX_EXTENSIONS_PATH so extensions can be found using 'resolve-interface' rather than 'load' with an absolute path. Signed-off-by: Ludovic Courtès Merges: #10607 --- guix/ui.scm | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index dafc04b20f7..78a58e353e1 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2447,26 +2447,17 @@ found." (define module ;; Check if there is a matching extension. - (match (search-path (extension-directories) - (format #f "~a.scm" command)) - (#f - (catch 'misc-error - (lambda () - (resolve-interface `(guix scripts ,command))) - (lambda _ - (let ((hint (command-hint command (commands)))) - (format (current-error-port) - (G_ "guix: ~a: command not found~%") command) - (when hint - (display-hint (G_ "Did you mean @code{~a}?") hint)) - (show-guix-usage))))) - (file - (load file) - (let ((maybe-extension-path - (format #f "/guix/extensions/~a.scm" command))) - (if (string-suffix? maybe-extension-path file) - (resolve-interface `(guix extensions ,command)) - (resolve-interface `(guix scripts ,command))))))) + (catch 'misc-error + (lambda () + (or (false-if-exception (resolve-interface `(guix scripts ,command))) + (resolve-interface `(guix extensions ,command)))) + (lambda _ + (let ((hint (command-hint command (commands)))) + (format (current-error-port) + (G_ "guix: ~a: command not found~%") command) + (when hint + (display-hint (G_ "Did you mean @code{~a}?") hint)) + (show-guix-usage))))) (let ((command-main (module-ref module (symbol-append 'guix- command)))) @@ -2490,6 +2481,9 @@ and signal handling have already been set up." ;; number of 'stat' calls per entry in %LOAD-PATH. Shamelessly remove it. (set! %load-extensions '(".scm")) + ;; Extensions take precedence over core commands. + (set! %load-path (append (extension-directories) %load-path)) + ;; Disable canonicalization so we don't don't stat unreasonably. (with-fluids ((%file-port-name-canonicalization #f)) (match args -- cgit v1.2.3