guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XDG_DATA_DIRS issue in execution environment on LTSP


From: Meiyo Peng
Subject: Re: XDG_DATA_DIRS issue in execution environment on LTSP
Date: Thu, 28 Mar 2019 09:55:13 +0800

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]