diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-08-17 15:32:11 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-08-21 16:00:23 +0200 |
| commit | bf1f18130f2b54a2bd1e8a57d6dae3a611573ee8 (patch) | |
| tree | 21b33708548ee64094e6e2566f9ad0367daf5ac4 | |
| parent | 9e4c90ea160066d0b8e23c1e73450e2fc9f68bea (diff) | |
ui: Fix not finding compiled files when loading extensions
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'
'/<example>/guix/extensions/foo.scm' would be searched under
'/path/to/site-ccache//<example>/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 <ludo@gnu.org>
Merges: #10607
| -rw-r--r-- | guix/ui.scm | 34 |
1 files 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." | |||
| 2447 | 2447 | ||
| 2448 | (define module | 2448 | (define module |
| 2449 | ;; Check if there is a matching extension. | 2449 | ;; Check if there is a matching extension. |
| 2450 | (match (search-path (extension-directories) | 2450 | (catch 'misc-error |
| 2451 | (format #f "~a.scm" command)) | 2451 | (lambda () |
| 2452 | (#f | 2452 | (or (false-if-exception (resolve-interface `(guix scripts ,command))) |
| 2453 | (catch 'misc-error | 2453 | (resolve-interface `(guix extensions ,command)))) |
| 2454 | (lambda () | 2454 | (lambda _ |
| 2455 | (resolve-interface `(guix scripts ,command))) | 2455 | (let ((hint (command-hint command (commands)))) |
| 2456 | (lambda _ | 2456 | (format (current-error-port) |
| 2457 | (let ((hint (command-hint command (commands)))) | 2457 | (G_ "guix: ~a: command not found~%") command) |
| 2458 | (format (current-error-port) | 2458 | (when hint |
| 2459 | (G_ "guix: ~a: command not found~%") command) | 2459 | (display-hint (G_ "Did you mean @code{~a}?") hint)) |
| 2460 | (when hint | 2460 | (show-guix-usage))))) |
| 2461 | (display-hint (G_ "Did you mean @code{~a}?") hint)) | ||
| 2462 | (show-guix-usage))))) | ||
| 2463 | (file | ||
| 2464 | (load file) | ||
| 2465 | (let ((maybe-extension-path | ||
| 2466 | (format #f "/guix/extensions/~a.scm" command))) | ||
| 2467 | (if (string-suffix? maybe-extension-path file) | ||
| 2468 | (resolve-interface `(guix extensions ,command)) | ||
| 2469 | (resolve-interface `(guix scripts ,command))))))) | ||
| 2470 | 2461 | ||
| 2471 | (let ((command-main (module-ref module | 2462 | (let ((command-main (module-ref module |
| 2472 | (symbol-append 'guix- command)))) | 2463 | (symbol-append 'guix- command)))) |
| @@ -2490,6 +2481,9 @@ and signal handling have already been set up." | |||
| 2490 | ;; number of 'stat' calls per entry in %LOAD-PATH. Shamelessly remove it. | 2481 | ;; number of 'stat' calls per entry in %LOAD-PATH. Shamelessly remove it. |
| 2491 | (set! %load-extensions '(".scm")) | 2482 | (set! %load-extensions '(".scm")) |
| 2492 | 2483 | ||
| 2484 | ;; Extensions take precedence over core commands. | ||
| 2485 | (set! %load-path (append (extension-directories) %load-path)) | ||
| 2486 | |||
| 2493 | ;; Disable canonicalization so we don't don't stat unreasonably. | 2487 | ;; Disable canonicalization so we don't don't stat unreasonably. |
| 2494 | (with-fluids ((%file-port-name-canonicalization #f)) | 2488 | (with-fluids ((%file-port-name-canonicalization #f)) |
| 2495 | (match args | 2489 | (match args |
