all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* XDG_DATA_DIRS issue in execution environment on LTSP
@ 2019-03-27 14:51 Giovanni Biscuolo
  2019-03-28  1:55 ` Meiyo Peng
  0 siblings, 1 reply; 5+ messages in thread
From: Giovanni Biscuolo @ 2019-03-27 14:51 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 5184 bytes --]

Hello,

I want to share this issue and show my "workaround" to fix it, please
send your comments on alternative ways or other caveats you may find in
my reasoning

I'm running Guix on top of Debian/stretch, recently I made Guix
environment the default execution one for my console and graphical
applications (bad idea?) and now I have to fix env every time I want to
run a Debian installed application

Since I'm connecting to my machine via an LTSP terminal, I followed this
guide https://wiki.debian.org/EnvironmentVariables#Quick_guide to have
the Guix profile automatically set up when I login via LDM; so now I
have this in my .profile:

--8<---------------cut here---------------start------------->8---
### Guix settings
#
# add Guix current path
export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
# add Guix infopath
export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
# set default Guix profile
export GUIX_PROFILE="$HOME/.guix-profile"
# source default Guix profile
. $GUIX_PROFILE/etc/profile
# set Guix locale path
export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
### end Guix
--8<---------------cut here---------------end--------------->8---

and this in my .bash_profile *and* .xsessionrc:

--8<---------------cut here---------------start------------->8---
if [ -f ~/.profile ]; then
    . ~/.profile
fi
--8<---------------cut here---------------end--------------->8---

and lastly this in $GUIX_PROFILE/etc/profile:

--8<---------------cut here---------------start------------->8---
# Source this file to define all the relevant environment variables in Bash
# for this profile.  You may want to define the 'GUIX_PROFILE' environment
# variable to point to the "visible" name of the profile, like this:
#
#  GUIX_PROFILE=/path/to/profile ; \
#  source /path/to/profile/etc/profile
#
# When GUIX_PROFILE is undefined, the various environment variables refer
# to this specific profile generation.

export PATH="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/bin:${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/sbin${PATH:+:}$PATH"
export GST_PLUGIN_SYSTEM_PATH="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/lib/gstreamer-1.0${GST_PLUGIN_SYSTEM_PATH:+:}$GST_PLUGIN_SYSTEM_PATH"
export XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
export GIO_EXTRA_MODULES="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/lib/gio/modules${GIO_EXTRA_MODULES:+:}$GIO_EXTRA_MODULES"
--8<---------------cut here---------------end--------------->8---

AFAIU it conforms to the suggested way to setup a working user profile:
right?

The problem here is I'm getting this env when I login and open a
terminal emulator:

--8<---------------cut here---------------start------------->8---
~ $ env | grep -i guix
GIO_EXTRA_MODULES=/home/giovanni/.guix-profile/lib/gio/modules
GST_PLUGIN_SYSTEM_PATH=/home/giovanni/.guix-profile/lib/gstreamer-1.0
GUIX_LOCPATH=/home/giovanni/.guix-profile/lib/locale
GUIX_PROFILE=/home/giovanni/.guix-profile
INFOPATH=/home/giovanni/.config/guix/current/share/info:
PATH=/home/giovanni/.guix-profile/bin:/home/giovanni/.guix-profile/sbin:/home/giovanni/.config/guix/current/bin:/usr/local/bin/Zotero_linux-x86_64:/home/giovanni/.local/bin:/home/giovanni/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/home/giovanni/bin:/home/giovanni/.local/bin:/home/giovanni/go/bin:/home/giovanni/bin:/home/giovanni/.local/bin
XDG_DATA_DIRS=/home/giovanni/.guix-profile/share
--8<---------------cut here---------------end--------------->8---

This causes some Debian installed GUI applications to chrash with a
GLib-GIO-ERROR like this (evince in this case, I also tried eom from
Mate and gnome-character-map):

--8<---------------cut here---------------start------------->8---
~ $ evince

(evince:26326): GLib-GIO-ERROR **: Settings schema 'org.gnome.Evince' is not installed

rilevato trace/breakpoint
--8<---------------cut here---------------end--------------->8---

At first I did not ralized it was an env problem, then looking at an
strace log it tunrs out that it reads gschema.compiled from my user Guix
profile and not from Debian standard folder [2]:

--8<---------------cut here---------------start------------->8---
openat(AT_FDCWD, "/home/giovanni/.guix-profile/share/glib-2.0/schemas/gschemas.compiled", O_RDONLY) = 12
--8<---------------cut here---------------end--------------->8---

[1] /usr/share/gnome:/usr/local/share/:/usr/share/ as documented here
https://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_starting_a_program_from_gui

To fix this issue now I do (in a terminal emulator):

--8<---------------cut here---------------start------------->8---
unset XDG_DATA_DIRS
export XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/share:/usr/share/gnome:/usr/local/share/:/usr/share/"
--8<---------------cut here---------------end--------------->8---

Now I should just "backport" this fix in my ~/.profile so it will be
applied to my graphical login session, too

WDYT? Thanks, Gio'

--
Giovanni Biscuolo

Xelera IT Infrastructures

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: XDG_DATA_DIRS issue in execution environment on LTSP
  2019-03-27 14:51 XDG_DATA_DIRS issue in execution environment on LTSP Giovanni Biscuolo
@ 2019-03-28  1:55 ` Meiyo Peng
  2019-03-28  2:35   ` Meiyo Peng
  2019-03-28 11:22   ` Giovanni Biscuolo
  0 siblings, 2 replies; 5+ messages in thread
From: Meiyo Peng @ 2019-03-28  1:55 UTC (permalink / raw)
  To: Giovanni Biscuolo; +Cc: guix-devel

Hi Giovanni,

Giovanni Biscuolo writes:

> I want to share this issue and show my "workaround" to fix it, please
> send your comments on alternative ways or other caveats you may find in
> my reasoning

Thank you for sharing you experience with us.

> I'm running Guix on top of Debian/stretch, recently I made Guix
> environment the default execution one for my console and graphical
> applications (bad idea?) and now I have to fix env every time I want to
> run a Debian installed application

I have a similar experience.  I run Guix on top of Debian Sid.

> Since I'm connecting to my machine via an LTSP terminal, I followed this
> guide https://wiki.debian.org/EnvironmentVariables#Quick_guide to have
> the Guix profile automatically set up when I login via LDM; so now I
> have this in my .profile:
>
> --8<---------------cut here---------------start------------->8---
> ### Guix settings
> #
> # add Guix current path
> export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
> # add Guix infopath
> export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
> # set default Guix profile
> export GUIX_PROFILE="$HOME/.guix-profile"
> # source default Guix profile
> . $GUIX_PROFILE/etc/profile
> # set Guix locale path
> export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
> ### end Guix
> --8<---------------cut here---------------end--------------->8---
>
> and this in my .bash_profile *and* .xsessionrc:
>
> --8<---------------cut here---------------start------------->8---
> if [ -f ~/.profile ]; then
>     . ~/.profile
> fi
> --8<---------------cut here---------------end--------------->8---
>
> and lastly this in $GUIX_PROFILE/etc/profile:
>
> --8<---------------cut here---------------start------------->8---
> # Source this file to define all the relevant environment variables in Bash
> # for this profile.  You may want to define the 'GUIX_PROFILE' environment
> # variable to point to the "visible" name of the profile, like this:
> #
> #  GUIX_PROFILE=/path/to/profile ; \
> #  source /path/to/profile/etc/profile
> #
> # When GUIX_PROFILE is undefined, the various environment variables refer
> # to this specific profile generation.
>
> export PATH="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/bin:${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/sbin${PATH:+:}$PATH"
> export GST_PLUGIN_SYSTEM_PATH="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/lib/gstreamer-1.0${GST_PLUGIN_SYSTEM_PATH:+:}$GST_PLUGIN_SYSTEM_PATH"
> export XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
> export GIO_EXTRA_MODULES="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/lib/gio/modules${GIO_EXTRA_MODULES:+:}$GIO_EXTRA_MODULES"
> --8<---------------cut here---------------end--------------->8---
>
> AFAIU it conforms to the suggested way to setup a working user profile:
> right?
>
> The problem here is I'm getting this env when I login and open a
> terminal emulator:
>
> --8<---------------cut here---------------start------------->8---
> ~ $ env | grep -i guix
> GIO_EXTRA_MODULES=/home/giovanni/.guix-profile/lib/gio/modules
> GST_PLUGIN_SYSTEM_PATH=/home/giovanni/.guix-profile/lib/gstreamer-1.0
> GUIX_LOCPATH=/home/giovanni/.guix-profile/lib/locale
> GUIX_PROFILE=/home/giovanni/.guix-profile
> INFOPATH=/home/giovanni/.config/guix/current/share/info:
> PATH=/home/giovanni/.guix-profile/bin:/home/giovanni/.guix-profile/sbin:/home/giovanni/.config/guix/current/bin:/usr/local/bin/Zotero_linux-x86_64:/home/giovanni/.local/bin:/home/giovanni/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/home/giovanni/bin:/home/giovanni/.local/bin:/home/giovanni/go/bin:/home/giovanni/bin:/home/giovanni/.local/bin
> XDG_DATA_DIRS=/home/giovanni/.guix-profile/share
> --8<---------------cut here---------------end--------------->8---
>
> This causes some Debian installed GUI applications to chrash with a
> GLib-GIO-ERROR like this (evince in this case, I also tried eom from
> Mate and gnome-character-map):
>
> --8<---------------cut here---------------start------------->8---
> ~ $ evince
>
> (evince:26326): GLib-GIO-ERROR **: Settings schema 'org.gnome.Evince' is not installed
>
> rilevato trace/breakpoint
> --8<---------------cut here---------------end--------------->8---
>
> At first I did not ralized it was an env problem, then looking at an
> strace log it tunrs out that it reads gschema.compiled from my user Guix
> profile and not from Debian standard folder [2]:
>
> --8<---------------cut here---------------start------------->8---
> openat(AT_FDCWD, "/home/giovanni/.guix-profile/share/glib-2.0/schemas/gschemas.compiled", O_RDONLY) = 12
> --8<---------------cut here---------------end--------------->8---
>
> [1] /usr/share/gnome:/usr/local/share/:/usr/share/ as documented here
> https://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_starting_a_program_from_gui
>
> To fix this issue now I do (in a terminal emulator):
>
> --8<---------------cut here---------------start------------->8---
> unset XDG_DATA_DIRS
> export XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/gvfl5wxrgalxjjmyp7cwgfj48bdd34n4-profile}/share:/usr/share/gnome:/usr/local/share/:/usr/share/"
> --8<---------------cut here---------------end--------------->8---
>
> Now I should just "backport" this fix in my ~/.profile so it will be
> applied to my graphical login session, too
>
> WDYT? Thanks, Gio'

According to the XDG Base Directory Specification [1]:

#+begin_quote
  If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
  If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg should be used.
#+end_quote

And according to my experience, $XDG_DATA_DIRS and $XDG_CONFIG_DIRS are
not set by default on Debian.  So they should be set to their default
values before adding extra paths to them.

Thus I have this code snippet in my login shell's config (fish rather
than bash).  Fish script is very easy to understand.  I think you can
translate it into bash.

#+begin_src fish
  if status is-login || status is-interactive
      set -gx MY_PROFILE "$HOME/.guix-profile"

      # Guix on foreign distros.
      # This test is a dirty hack.
      if test -d /var/guix && ! test -L /run/current-system
          # Environment
          set -gx ROOT_PROFILE "/var/guix/profiles/per-user/root/guix-profile"
          set -gx GUIX_LOCPATH "$ROOT_PROFILE/lib/locale"
          set -gx SSL_CERT_DIR "$ROOT_PROFILE/etc/ssl/certs"
          set -gx SSL_CERT_FILE "$ROOT_PROFILE/etc/ssl/certs/ca-certificates.crt"

          # XDG
          # ==========> Look at here! <=========
          # Set $XDG_CONFIG_DIRS and $XDG_DATA_DIRS to their default
          # values if they are not set.
          test "$XDG_CONFIG_DIRS" = "" && set -gx XDG_CONFIG_DIRS "/etc/xdg"
          test "$XDG_DATA_DIRS" = "" && set -gx XDG_DATA_DIRS "/usr/local/share:/usr/share"
          set -gx XDG_CONFIG_DIRS "$MY_PROFILE/etc/xdg:$XDG_CONFIG_DIRS"
          set -gx XDG_DATA_DIRS "$MY_PROFILE/share:$XDG_DATA_DIRS"
          # ==========> Look at here! <=========

          # Source my etc/profile
          set -gx GUIX_PROFILE $MY_PROFILE
          fenv source $MY_PROFILE/etc/profile
          set -eu GUIX_PROFILE

          # $PATH
          # add_path is a function defined by me.  It adds the argument
          # into $PATH
          add_path $MY_PROFILE/sbin
          add_path $MY_PROFILE/bin
          add_path $XDG_CONFIG_HOME/guix/current/bin
      end
  end
#+end_src


[1]. XDG Base Directory Specification
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html


--
Meiyo Peng
https://www.pengmeiyu.com/

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

* Re: XDG_DATA_DIRS issue in execution environment on LTSP
  2019-03-28  1:55 ` Meiyo Peng
@ 2019-03-28  2:35   ` Meiyo Peng
  2019-03-28 11:22   ` Giovanni Biscuolo
  1 sibling, 0 replies; 5+ messages in thread
From: Meiyo Peng @ 2019-03-28  2:35 UTC (permalink / raw)
  To: Giovanni Biscuolo; +Cc: guix-devel

Hi,

Meiyo Peng writes:

> #+begin_src fish
>   if status is-login || status is-interactive
>       set -gx MY_PROFILE "$HOME/.guix-profile"
>
>       # Guix on foreign distros.
>       # This test is a dirty hack.
>       if test -d /var/guix && ! test -L /run/current-system
>           # Environment
>           set -gx ROOT_PROFILE "/var/guix/profiles/per-user/root/guix-profile"
>           set -gx GUIX_LOCPATH "$ROOT_PROFILE/lib/locale"
>           set -gx SSL_CERT_DIR "$ROOT_PROFILE/etc/ssl/certs"
>           set -gx SSL_CERT_FILE "$ROOT_PROFILE/etc/ssl/certs/ca-certificates.crt"
>
>           # XDG
>           # ==========> Look at here! <=========
>           # Set $XDG_CONFIG_DIRS and $XDG_DATA_DIRS to their default
>           # values if they are not set.
>           test "$XDG_CONFIG_DIRS" = "" && set -gx XDG_CONFIG_DIRS "/etc/xdg"
>           test "$XDG_DATA_DIRS" = "" && set -gx XDG_DATA_DIRS "/usr/local/share:/usr/share"
>           set -gx XDG_CONFIG_DIRS "$MY_PROFILE/etc/xdg:$XDG_CONFIG_DIRS"
>           set -gx XDG_DATA_DIRS "$MY_PROFILE/share:$XDG_DATA_DIRS"
>           # ==========> Look at here! <=========
>
>           # Source my etc/profile
>           set -gx GUIX_PROFILE $MY_PROFILE
>           fenv source $MY_PROFILE/etc/profile
>           set -eu GUIX_PROFILE
>
>           # $PATH
>           # add_path is a function defined by me.  It adds the argument
>           # into $PATH
>           add_path $MY_PROFILE/sbin
>           add_path $MY_PROFILE/bin
>           add_path $XDG_CONFIG_HOME/guix/current/bin
>       end
>   end
> #+end_src

I made a minor mistake here.  `set -eu` is invalid fish command.  `set
-eu GUIX_PROFILE` should be `set -e GUIX_PROFILE`.  It means erase the
$GUIX_PROFILE environment variable.

--
Meiyo Peng
https://www.pengmeiyu.com/

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

* Re: XDG_DATA_DIRS issue in execution environment on LTSP
  2019-03-28  1:55 ` Meiyo Peng
  2019-03-28  2:35   ` Meiyo Peng
@ 2019-03-28 11:22   ` Giovanni Biscuolo
  2019-03-28 11:51     ` Meiyo Peng
  1 sibling, 1 reply; 5+ messages in thread
From: Giovanni Biscuolo @ 2019-03-28 11:22 UTC (permalink / raw)
  To: Meiyo Peng; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]

Hi Meiyo,

Meiyo Peng <meiyo@riseup.net> writes:

[...]

> According to the XDG Base Directory Specification [1]:
>
> #+begin_quote
>   If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
>   If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg should be used.
> #+end_quote

Thanks for the quote, I missed to read that

> And according to my experience, $XDG_DATA_DIRS and $XDG_CONFIG_DIRS are
> not set by default on Debian.  So they should be set to their default
> values before adding extra paths to them.

Ha ha: now I understand!

> Thus I have this code snippet in my login shell's config (fish rather
> than bash).  Fish script is very easy to understand.  I think you can
> translate it into bash.

Yes, it's very clear, thanks!

>
> #+begin_src fish
>   if status is-login || status is-interactive
>       set -gx MY_PROFILE "$HOME/.guix-profile"
>
>       # Guix on foreign distros.
>       # This test is a dirty hack.
>       if test -d /var/guix && ! test -L /run/current-system

This is to distingush if Guix is running natively (which means we do not
need to "manually" set our env) from Guic on forein distros: right?

[...]

>           # XDG
>           # ==========> Look at here! <=========
>           # Set $XDG_CONFIG_DIRS and $XDG_DATA_DIRS to their default
>           # values if they are not set.
>           test "$XDG_CONFIG_DIRS" = "" && set -gx XDG_CONFIG_DIRS "/etc/xdg"
>           test "$XDG_DATA_DIRS" = "" && set -gx XDG_DATA_DIRS "/usr/local/share:/usr/share"

Got it: I have to port this to my bash ~/.profile, thanks!

[...]

>
> [1]. XDG Base Directory Specification
> https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Thanks! Gio'

-- 
Giovanni Biscuolo

Xelera IT Infrastructures

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: XDG_DATA_DIRS issue in execution environment on LTSP
  2019-03-28 11:22   ` Giovanni Biscuolo
@ 2019-03-28 11:51     ` Meiyo Peng
  0 siblings, 0 replies; 5+ messages in thread
From: Meiyo Peng @ 2019-03-28 11:51 UTC (permalink / raw)
  To: Giovanni Biscuolo; +Cc: guix-devel

Hi Giovanni,

Giovanni Biscuolo writes:

>> #+begin_src fish
>>   if status is-login || status is-interactive
>>       set -gx MY_PROFILE "$HOME/.guix-profile"
>>
>>       # Guix on foreign distros.
>>       # This test is a dirty hack.
>>       if test -d /var/guix && ! test -L /run/current-system
>
> This is to distingush if Guix is running natively (which means we do not
> need to "manually" set our env) from Guic on forein distros: right?

Right.  Guix System (the former GuixSD) takes care of all the details
for us.  So we don't need to manually set these environment variables
for Guix System.


--
Meiyo Peng
https://www.pengmeiyu.com/

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

end of thread, other threads:[~2019-03-28 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 14:51 XDG_DATA_DIRS issue in execution environment on LTSP Giovanni Biscuolo
2019-03-28  1:55 ` Meiyo Peng
2019-03-28  2:35   ` Meiyo Peng
2019-03-28 11:22   ` Giovanni Biscuolo
2019-03-28 11:51     ` Meiyo Peng

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.