unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* consider setting the necessary environment variables
@ 2024-03-17 11:40 Thomas Bennett
  2024-03-17 19:31 ` Carlo Zancanaro
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bennett @ 2024-03-17 11:40 UTC (permalink / raw)
  To: help-guix

Hello Guix community,

I have an issue where my root user seems to be unable to have its 
environment set.

As advised, I put the following lines at the end of my shell rc file

(as root, using bash)

# tail /root/.bashrc
[...]

GUIX_PROFILE="/root/.config/guix/current"
. "$GUIX_PROFILE/etc/profile"

And it is correctly registered since:

# echo $GUIX_PROFILE
/root/.config/guix/current

However, the problem is I can install packages but I'm not able to use 
them. For instance with bat binary:

root@brain ~# guix package -i bat
The following package will be upgraded: bat (dependencies or package 
changed)

The following derivation will be built:
     /gnu/store/mwznz6gqq4lrxl5pmql8mxixcmhmnnfy-profile.drv

building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
generating GdkPixbuf loaders cache...
generating GLib schema cache...
creating GTK+ icon theme cache...
building cache files for GTK+ input methods...
|building directory of Info manuals...
building XDG desktop file cache...
building XDG MIME database...
building profile with 4 packages...
hint: Consider setting the necessary environment variables by running:

     GUIX_PROFILE="/root/.guix-prof
     . "$GUIX_PROFILE/etc/profile"

Alternately, see `guix package --search-paths -p "/root/.guix-profile"'.

# guix package --search-paths -p "/root/.guix-profile"
export PATH="/root/.guix-profile/bin:/root/.guix-profile/sbin"
export EMACSLOADPATH="/root/.guix-profile/share/emacs/site-lisp"
export INFOPATH="/root/.guix-profile/share/info"

root@brain /home/tomi# bat
bash: bat: command not found

When doing a full system upgrade with guix pull and guix package -u, 
everything seems to operate fine and at the end, the message

hint: Consider setting the necessary environment variables by running:

     GUIX_PROFILE="/root/.guix-profile"
     . "$GUIX_PROFILE/etc/profile"

Alternately, see `guix package --search-paths -p "/root/.guix-profile"'.

appears.

I tried to manually source "$GUIX_PROFILE/etc/profile" but it's no better.


Thank you for your help,

Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: consider setting the necessary environment variables
  2024-03-17 11:40 consider setting the necessary environment variables Thomas Bennett
@ 2024-03-17 19:31 ` Carlo Zancanaro
  0 siblings, 0 replies; 2+ messages in thread
From: Carlo Zancanaro @ 2024-03-17 19:31 UTC (permalink / raw)
  To: Thomas Bennett; +Cc: help-guix

Hi Thomas,

On Sun, Mar 17 2024, Thomas Bennett wrote:
> I have an issue where my root user seems to be unable to have its
> environment set.

That sounds annoying! Hopefully we can figure out what's going wrong for
you. 🙂

> # tail /root/.bashrc
> [...]
>
> GUIX_PROFILE="/root/.config/guix/current"
> . "$GUIX_PROFILE/etc/profile"

This sets the GUIX_PROFILE variable to the current Guix profile. This
adds the "guix" command to your PATH, but not any of your installed
packages.

There are two main profiles that you need to source. One if the current
Guix profile, in $HOME/.config/guix/current, and the other is your
user's package profile, in $HOME/.guix-profile.

The former is suggested when you run "guix pull", and the latter is
suggested when you run "guix package" commands (including shorthands
like "guix install"). We can see this in your output:

> root@brain ~# guix package -i bat
> [...]
> hint: Consider setting the necessary environment variables by running:
>
>     GUIX_PROFILE="/root/.guix-profile
>     . "$GUIX_PROFILE/etc/profile"
>
> Alternately, see `guix package --search-paths -p "/root/.guix-profile"'.

You mention:

> I tried to manually source "$GUIX_PROFILE/etc/profile" but it's no
> better.

but it's not clear whether you set GUIX_PROFILE to /root/.guix-profile
before doing so.

Can you try using this as your Guix initialisation code in your shell?

--8<---------------cut here---------------start------------->8---
GUIX_PROFILE="$HOME/.guix-profile"
. "$GUIX_PROFILE/etc/profile"
GUIX_PROFILE="$HOME/.config/guix/current"
. "$GUIX_PROFILE/etc/profile"
unset GUIX_PROFILE
--8<---------------cut here---------------end--------------->8---

As an additional gotcha that might cause problems for you in future: the
usual advice in Guix is to source your profiles in .bash_profile rather
than .bashrc.  This allows "guix shell" to source .bashrc in a --pure
environment without also including your entire user profile.

Carlo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-17 19:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-17 11:40 consider setting the necessary environment variables Thomas Bennett
2024-03-17 19:31 ` Carlo Zancanaro

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).