diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2025-11-04 23:52:54 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-12-05 14:54:38 +0100 |
| commit | 7fd60bfc0b088ee7d66e3b5676695a04d2ee01d9 (patch) | |
| tree | c1cc08dee9fe1ab97e908e97ba75747ea4f299fc | |
| parent | a560be0dd9e9132c88bea5c4aa03a1486311cdc5 (diff) | |
shell: Create cached profile directory once connected to the daemon.
Fixes a regression introduced in d12c4452a49b355369636de1dfc766b5bad6437b,
where ‘guix shell’, on a fresh installation, would attempt to create the
cached profile directory under /var/guix/profiles/per-user/$USER, which only
guix-daemon can do, on the user’s first connection.
* guix/scripts/shell.scm (options-with-caching): Remove ‘mkdir-p’ call for
ROOT’s parent directory. Add ‘create-gc-root-directory?’ key to the result.
* guix/scripts/environment.scm (guix-environment*): Honor
‘create-gc-root-directory?’ key.
Fixes: guix/guix#126
Reported-by: Maxim Cournoyer <maxim@guixotic.coop>
Change-Id: I782461c80c254467108c6b8d676d269866795746
| -rw-r--r-- | guix/scripts/environment.scm | 2 | ||||
| -rw-r--r-- | guix/scripts/shell.scm | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 15b84afb7fd..1b3b1312ea3 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -1235,6 +1235,8 @@ command-line option processing with 'parse-command-line'." (if prof-drv (list prof-drv) '()) (if (derivation? bash) (list bash) '())))) (mwhen gc-root + (mwhen (assoc-ref opts 'create-gc-root-directory?) + (return (mkdir-p (dirname gc-root)))) (register-gc-root profile gc-root)) (mwhen (assoc-ref opts 'check?) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index d8fd71bc24b..1966264298d 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -261,10 +261,14 @@ cache) or a 'gc-root' key (to add the profile to cache)." opts))) ;load right away (if (and root (not (assq-ref opts 'gc-root))) (begin - (if stat - (delete-file root) - (mkdir-p (dirname root))) - (alist-cons 'gc-root root opts)) + (when stat + (delete-file root)) + ;; Note: Delay the creation of ROOT's parent directory: a + ;; connection must first be made to the daemon so that it + ;; creates /var/guix/profiles/per-user/$USER if needed. + (alist-cons 'gc-root root + (alist-cons 'create-gc-root-directory? #t + opts))) opts)))) (define (auto-detect-manifest opts) |
