GNU bug report logs -
#36785
'sudo guix pull' failure in the profile migration code
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hi Julien,
Julien Lepiller <julien <at> lepiller.eu> skribis:
> Le 26 juillet 2019 01:03:08 GMT+02:00, "Ludovic Courtès" <ludo <at> gnu.org> a écrit :
[...]
>>;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks.
>>Move
>> ;; them to %PROFILE-DIRECTORY.
>> (unless (string=? %profile-directory
>> (dirname (canonicalize-profile %user-profile-directory)))
>> (migrate-generations %user-profile-directory %profile-directory))
[...]
> Could there be some veird interaction between sudo and these %profile-directory and %user-profile-directory variables?
Indeed. I added ‘pk’ calls to print ‘%profile-directory’ and
(canonicalize-profile %user-profile-directory), and here’s what I see
with ‘sudo’:
--8<---------------cut here---------------start------------->8---
$ sudo -E ./pre-inst-env guix pull
;;; (pd "/var/guix/profiles/per-user/root")
;;; (upd "/home/ludo/.config/guix/current")
Migrating profile generations to '/var/guix/profiles/per-user/root'...
guix pull: error: symlink: Dosiero jam ekzistas: "/var/guix/profiles/per-user/root/current-guix"
--8<---------------cut here---------------end--------------->8---
‘%user-profile-directory’ is computed as a function of $HOME, which is
unchanged when using ‘sudo’, whereas ‘%profile-directory’ is computed as
a function of $USER.
I think $HOME should always prevail over the home directory defined in
/etc/passwd, so think we should not change the way
‘%user-profile-directory’ is computed.
We could do this:
[Message part 2 (text/x-patch, inline)]
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1721,7 +1721,8 @@ because the NUMBER is zero.)"
(define %profile-directory
(string-append %state-directory "/profiles/"
- (or (and=> (or (getenv "USER")
+ (or (and=> (or (getenv "SUDO_USER")
+ (getenv "USER")
(getenv "LOGNAME"))
(cut string-append "per-user/" <>))
"default")))
[Message part 3 (text/plain, inline)]
… but then ‘sudo guix pull’ won’t update root’s guix at all.
Otherwise I’m thinking of this gross hack:
[Message part 4 (text/x-patch, inline)]
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 54bbaddf30..8d8a8aa889 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -293,8 +293,9 @@ true, display what would be built without actually building it."
;; In 0.15.0+ we'd create ~/.config/guix/current-[0-9]*-link symlinks. Move
;; them to %PROFILE-DIRECTORY.
- (unless (string=? %profile-directory
- (dirname (canonicalize-profile %user-profile-directory)))
+ (unless (or (getenv "SUDO_USER")
+ (string=? (pk 'pd %profile-directory)
+ (dirname (pk 'upd (canonicalize-profile %user-profile-directory)))))
(migrate-generations %user-profile-directory %profile-directory))
;; Make sure ~/.config/guix/current points to /var/guix/profiles/….
[Message part 5 (text/plain, inline)]
I think it’s acceptable because that’s “throw away” code anyway, and
it’s not supposed to be triggered these days.
Thoughts?
Ludo’.
This bug report was last modified 5 years and 235 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.