From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Subject: bug#30728: guix-install.sh doesn't work if run with "sudo" Date: Mon, 26 Mar 2018 10:05:50 +0200 Message-ID: <87efk79s81.fsf@lassieur.org> References: <87zi3lh6mb.fsf@lassieur.org> <871sgbdj2x.fsf@lassieur.org> <87d0zsn391.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0N8p-0001Hf-ND for bug-guix@gnu.org; Mon, 26 Mar 2018 04:06:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0N8k-0007x5-La for bug-guix@gnu.org; Mon, 26 Mar 2018 04:06:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:45696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0N8k-0007wi-EH for bug-guix@gnu.org; Mon, 26 Mar 2018 04:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f0N8k-0001Iz-4z for bug-guix@gnu.org; Mon, 26 Mar 2018 04:06:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87d0zsn391.fsf@gmail.com> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Chris Marusich Cc: 30728@debbugs.gnu.org Hi Chris, Chris Marusich writes: > Clément Lassieur writes: > >> Clément Lassieur writes: >> >>> Hi, >>> >>> My system is Ubuntu 16.04. >>> >>> I ran './guix-install.sh' and got the message: "This script must be run >>> as root.". So I ran 'sudo ./guix-install.sh' and got an error message >>> saying that: >>> >>> GUIX_PROFILE="${HOME}/.guix-profile" >>> source "${GUIX_PROFILE}/etc/profile" >>> >>> the 'source' command doesn't work because ${GUIX_PROFILE} was never >>> created, ${HOME} being /home/clement, not /root. >>> >>> To recover from this I had to manually delete /var/guix and /gnu, log as >>> root with 'su', and start again. >>> >>> Clément >> >> I believe the script should install Guix in the user's home directory, >> not in ~root. > > The manual says (see: (guix) Binary Installation): > > 3. Make ‘root’’s profile available under ‘~/.guix-profile’: > > # ln -sf /var/guix/profiles/per-user/root/guix-profile \ > ~root/.guix-profile I think the manual is wrong here. This only makes sense if the user is 'root'. Otherwise, the user would expect Guix to be installed in their home, not in root's home. We could use the HOME and USER environment variables like this: # ln -sf /var/guix/profiles/per-user/$USER/guix-profile $HOME/.guix-profile Thus, even if 'sudo' decides to change these environment variables, it will still be consistent. > Source ‘etc/profile’ to augment ‘PATH’ and other relevant > environment variables: > > # GUIX_PROFILE=$HOME/.guix-profile ; \ > source $GUIX_PROFILE/etc/profile > > I believe the expectation here is that $HOME will expand to root's home > directory. Look at the previous ln invocation: we set up a symlink for > the .guix-profile in root's home directory, so it's pretty clear that > $HOME/.guix-profile is supposed to point to that profile. > > I think there is a tacit assumption in the manual and the > guix-install.sh script that the HOME environment variable will refer to > root's home directory, which is not always true. For example, on > current Ubuntu, if you run sudo with no arguments, you will find that > the HOME environment variable still points to your unprivileged user's > home directory, not to root's home directory. This is because sudo can > be configured in many ways, and on Ubuntu, they have chosen to configure > it in that way. On other systems, it might behave differently.