* Creating user profiles @ 2013-01-13 13:23 Andreas Enge 2013-01-13 22:05 ` Ludovic Courtès 0 siblings, 1 reply; 4+ messages in thread From: Andreas Enge @ 2013-01-13 13:23 UTC (permalink / raw) To: bug-guix [-- Attachment #1: Type: text/plain, Size: 1818 bytes --] Following the commit: commit b9e5c0a949fa627da55ea53fd71dfa96ad8a2b4b guix-package: Create ~/.guix-profile when it doesn't exist. I finally dropped giving the explicit profile parameter to guix-package. This results in the following error when installing a package: Backtrace: In ice-9/boot-9.scm: 149: 12 [catch #t #<catch-closure 12f39c0> ...] 157: 11 [#<procedure 128f0f0 ()>] In unknown file: ?: 10 [catch-closure] In ice-9/boot-9.scm: 63: 9 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 407: 8 [eval # #] In unknown file: ?: 7 [call-with-input-string "(apply (module-ref (resolve-interface '(guix-package)) 'guix-package) (cdr (command-line)))" ...] In ice-9/command-line.scm: 174: 6 [#<procedure 120e2a0 at ice-9/command-line.scm:169:3 (port)> #<input: string 10b60d0>] In unknown file: ?: 5 [eval (apply (module-ref # #) (cdr #)) #<directory (guile-user) 12f5d80>] In ice-9/boot-9.scm: 149: 4 [catch srfi-34 #<procedure 1290c40 at guix/ui.scm:71:2 ()> ...] 157: 3 [#<procedure 1753870 ()>] In /usr/local/bin/guix-package: 475: 2 [#<procedure 13b8c60 at /usr/local/bin/guix-package:468:4 ()>] 409: 1 [process-actions (# #)] In unknown file: ?: 0 [symlink "/nix/store/g4bnzikcjgdcgmcj7by815wb9ykz470l-user- environment" ...] In fact, a symbolic link $HOME/.guix-profile is created to the non-existing file /usr/local/guix-git/var/nix/profiles/per-user/privat/guix-profile (where /usr/local/guix-git/ is my installation prefix). The user environment /nix/store/g4bnzikcjgdcgmcj7by815wb9ykz470l-user- environment exists in the nix store. I think the problem is that only the directory /usr/local/guix- git/var/nix/profiles exists, but that it is empty; maybe one should first create the directory $PREFIX/var/nix/profiles/per-user/$USER if it does not exist yet? Andreas [-- Attachment #2: Type: text/html, Size: 7801 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Creating user profiles 2013-01-13 13:23 Creating user profiles Andreas Enge @ 2013-01-13 22:05 ` Ludovic Courtès 2013-01-13 22:31 ` Andreas Enge 0 siblings, 1 reply; 4+ messages in thread From: Ludovic Courtès @ 2013-01-13 22:05 UTC (permalink / raw) To: Andreas Enge; +Cc: bug-guix [-- Attachment #1: Type: text/plain, Size: 406 bytes --] Hello! Andreas Enge <andreas@enge.fr> skribis: > I think the problem is that only the directory /usr/local/guix- > git/var/nix/profiles exists, but that it is empty; maybe one should first > create the directory $PREFIX/var/nix/profiles/per-user/$USER if it does not > exist yet? Right, good point. (Apparently Nix’s manual doesn’t mention it either.) So here’s what I would do: [-- Attachment #2: Type: text/x-patch, Size: 2695 bytes --] --- a/doc/guix.texi +++ b/doc/guix.texi @@ -233,6 +233,16 @@ The @code{guix-daemon} program may then be run as @code{root} with: # guix-daemon --build-users-group=guix-builder @end example +In such a multi-user setup, @dfn{user profiles}---i.e., the set of +user-installed packages as seen by @command{guix-package} +(@pxref{Invoking guix-package})---must be stored in a place registered +as a @dfn{garbage-collector root}. That directory is normally +@code{@var{localstatedir}/profiles/per-user/@var{user}}, where +@var{localstatedir} is the value passed to @code{configure} as +@code{--localstatedir}, and @var{user} is the user name. This directory +must be created by @code{root}, with @var{user} as the owner. When it +does not exist, @command{guix-package} emits an error about it. + Guix may also be used in a single-user setup, with @command{guix-daemon} running as a unprivileged user. However, to maximize non-interference of build processes, the daemon still needs to perform certain operations diff --git a/guix-package.in b/guix-package.in index 450d09e..ec09cc4 100644 --- a/guix-package.in +++ b/guix-package.in @@ -36,6 +36,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ #:use-module (guix packages) #:use-module (guix utils) #:use-module (guix config) + #:use-module ((guix build utils) #:select (directory-exists?)) #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -465,6 +466,25 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n")) (not (file-exists? %user-environment-directory))) (symlink %current-profile %user-environment-directory)) + ;; Attempt to create /…/profiles/per-user/$USER if needed. + (unless (or (not (equal? (assoc-ref opts 'profile) %current-profile)) + (directory-exists? %profile-directory)) + (catch 'system-error + (lambda () + (mkdir %profile-directory)) + (lambda args + ;; Often, we cannot create %PROFILE-DIRECTORY because its + ;; parent directory is root-owned and we're running + ;; unprivileged. + (format (current-error-port) + (_ "error: while creating directory `~a': ~a~%") + %profile-directory + (strerror (system-error-errno args))) + (format (current-error-port) + (_ "Please create the `~a' directory, with you as the owner.~%") + %profile-directory) + (exit 1)))) + (with-error-handling (or (process-query opts) (parameterize ((%guile-for-build [-- Attachment #3: Type: text/plain, Size: 30 bytes --] WDYT? Thanks, Ludo’. ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Creating user profiles 2013-01-13 22:05 ` Ludovic Courtès @ 2013-01-13 22:31 ` Andreas Enge 2013-01-13 22:45 ` Ludovic Courtès 0 siblings, 1 reply; 4+ messages in thread From: Andreas Enge @ 2013-01-13 22:31 UTC (permalink / raw) To: Ludovic Courtès; +Cc: bug-guix [-- Attachment #1: Type: text/plain, Size: 2512 bytes --] Am Sonntag, 13. Januar 2013 schrieb Ludovic Courtès: > Right, good point. (Apparently Nix’s manual doesn’t mention it either.) > So here’s what I would do: I simply applied the patch, and it seems to be part of the solution. Upon a first run of "guix-package --list-available", I obtained the error message inviting me to create the directory, which I did. The next call succeeded. But now $HOME/.guix-profile points to the non-existing /usr/local/guix-git/var/nix/profiles/per-user/privat/guix-profile, and I get the error: Backtrace: In ice-9/boot-9.scm: 149: 9 [catch #t #<catch-closure 14e29c0> ...] 157: 8 [#<procedure 147e0f0 ()>] In unknown file: ?: 7 [catch-closure] In ice-9/boot-9.scm: 63: 6 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 407: 5 [eval # #] In unknown file: ?: 4 [call-with-input-string "(apply (module-ref (resolve-interface '(guix-package)) 'guix-package) (cdr (command-line)))" ...] In ice-9/command-line.scm: 174: 3 [#<procedure 1415500 at ice-9/command-line.scm:169:3 (port)> #<input: string 12a51a0>] In unknown file: ?: 2 [eval (apply (module-ref # #) (cdr #)) #<directory (guile-user) 14e4d80>] In /usr/local/bin/guix-package: 467: 1 [guix-package "--list-available"] In unknown file: ?: 0 [symlink "/usr/local/guix-git/var/nix/profiles/per- user/privat/guix-profile" ...] ERROR: In procedure symlink: ERROR: In procedure symlink: File exists The problem is that the call to "guix-package --list-available" does not actually create anything in the per-user profile directory. After deleting $HOME/.guix-profile again and running "guix-package -i hello", the per-user profile directory contains a symbolic link guix- profile-1-link to a user environment in the nix store, and a symbolic link guix-profile to guix-profile-1-link, and $HOME/.guix-profile points to the right thing. Then "guix-package --list-available" succeeds. Now I can even remove the hello package, since then the per-user profile directory contains a link to the empty user environment in the nix store. I would suggest the following: Before making the $HOME/.guix-profile symlink, check for the guix-profile symlink in the per-user profile directory. If it does not exist, create it as a link to the empty user environment. So there will always be guix-profile-1-link linking to the empty directory, which might also be useful for roll back (never delete this first empty environment). Andreas [-- Attachment #2: Type: text/html, Size: 8820 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Creating user profiles 2013-01-13 22:31 ` Andreas Enge @ 2013-01-13 22:45 ` Ludovic Courtès 0 siblings, 0 replies; 4+ messages in thread From: Ludovic Courtès @ 2013-01-13 22:45 UTC (permalink / raw) To: Andreas Enge; +Cc: bug-guix Andreas Enge <andreas@enge.fr> skribis: > I simply applied the patch, and it seems to be part of the solution. > Upon a first run of "guix-package --list-available", I obtained the error > message inviting me to create the directory, which I did. The next call > succeeded. But now $HOME/.guix-profile points to the non-existing > /usr/local/guix-git/var/nix/profiles/per-user/privat/guix-profile, and I > get the error: [...] > ?: 0 [symlink "/usr/local/guix-git/var/nix/profiles/per- > user/privat/guix-profile" ...] > > ERROR: In procedure symlink: > ERROR: In procedure symlink: File exists Aah, I see. That’s because it did (file-exists? ".guix-profile"), but this uses stat(2). So here, because .guix-profile was a dangling symlink, it returned #f, even though the symlink actually existed. I fixed it using ‘lstat’ instead. [...] > I would suggest the following: Before making the $HOME/.guix-profile > symlink, check for the guix-profile symlink in the per-user profile > directory. If it does not exist, create it as a link to the empty user > environment. So there will always be guix-profile-1-link linking to the > empty directory, which might also be useful for roll back (never delete > this first empty environment). Having this empty user environment on disk should not be needed because internally, ‘profile-manifests’ explicitly checks whether the profile exists, and returns an empty manifest if it doesn’t. So I’m committing the patch, minus the above bug. Thanks for the very quick feedback! Ludo’. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-13 22:45 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-13 13:23 Creating user profiles Andreas Enge 2013-01-13 22:05 ` Ludovic Courtès 2013-01-13 22:31 ` Andreas Enge 2013-01-13 22:45 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).