GNU bug report logs - #59474
Guix Home generated .profile sets XDG_ vars that break GDM+Gnome login on foreign distros

Previous Next

Package: guix;

Reported by: Matt Armstrong <matt <at> rfc20.org>

Date: Tue, 22 Nov 2022 06:03:01 UTC

Severity: normal

Done: Andrew Tropin <andrew <at> trop.in>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59474 in the body.
You can then email your comments to 59474 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#59474; Package guix. (Tue, 22 Nov 2022 06:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Armstrong <matt <at> rfc20.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Tue, 22 Nov 2022 06:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matt Armstrong <matt <at> rfc20.org>
To: bug-guix <at> gnu.org
Subject: Guix Home generated .profile sets XDG_ vars that break GDM+Gnome
 login on foreign distros
Date: Mon, 21 Nov 2022 22:02:07 -0800
I am experimenting with Guix Home on Debian Testing, using GDM+Gnome.
The .profile generated by "guix home reconfigure" broke logging in to
the Gnome desktop.  The gnome session would die, failing to initialize
what it considered to be essential things, and return to the login
screen I could log in to a tty, and was able to undo the new .profile
and get back to a working system.

The home-configuration.scm I used was generated by "guix home import"
and was quite simple:

----------------------------------------------------------------------
(use-modules (gnu home)
             (gnu packages)
             (gnu services)
             (guix gexp)
             (gnu home services shells))

(home-environment
  ;; Below is the list of packages that will show up in your
  ;; Home profile, under ~/.guix-home/profile.
  (packages (specifications->packages (list "glibc-locales")))

  ;; Below is the list of Home services.  To search for available
  ;; services, run 'guix home search KEYWORD' in a terminal.
  (services
   (list (service home-bash-service-type
                  (home-bash-configuration
                   (aliases '(("ls" . "ls --color=auto")))
                   (bashrc (list (local-file ".bashrc" "bashrc")))
                   (bash-logout (list (local-file ".bash_logout"
                                                  "bash_logout"))))))))
----------------------------------------------------------------------

Note: a stock GDM+Gnome setup runs the user's login shell when logging
in via the GDM display manager, and this shell execs
gnome-session-binary.  This doesn't necessarily happen with other
display managers or other desktop environments, so on those systems the
Guix Home .profile may not even run before the DE is initialized.
Nearly all of my time debugging this was spent figuring this out!  :-)

The .profile file generated by Guix Home is this:

----------------------------------------------------------------------
HOME_ENVIRONMENT=$HOME/.guix-home
. $HOME_ENVIRONMENT/setup-environment
$HOME_ENVIRONMENT/on-first-login
----------------------------------------------------------------------

The first thing I see is that $HOME/.guix-home/seutp-environment is
modifying various XDG_ variables incorrectly.  It prepends new values
without honor the variable's default value if it doesn't happen to be
set already.

For example, if XDG_DATA_DIRS is not set its default value is
"/usr/local/share/:/usr/share/".

But .guix-home/setup-environment will instead prepend a value without
checking, leaving XDG_DATA_DIRS set incorrectly to
"$HOME/.guix-home/profile/share:" when it should be
"$HOME/.guix-home/profile/share:/usr/local/share/:/usr/share/".

See this code in setup-environment:

case $XDG_DATA_DIRS in
  *$HOME_ENVIRONMENT/profile/share*) ;;
  *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
esac

The correct idiom is this:

XDG_DATA_DIRS=PATH_TO_PREPEND:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}

or

XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}:PATH_TO_APPEND

The above is what I see in various Nix and Snap configuration files.

Because I have a few other things installed that modify XDG_DATA_DIRS
before Guix Home does, Guix Home doesn't break that particular variable.

It did break XDG_CONFIG_DIRS, since Guix Home was setting it to
"$HOME/.guix-home/profile/etc/xdg:".  I worked around this problem by
running this code before Guix Home's .profile:

    # Note: when XDG_CONFIG_DIRS is not set Guix home sets
    # XDG_CONFIG_DIRS="$HOME/.guix-home/profile/etc/xdg:", which removes
    # the default "/etc/xdg" value.
    if [[ -z $XDG_CONFIG_DIRS ]]; then
        XDG_CONFIG_DIRS=/etc/xdg
    fi

    # Note: when XDG_DATA_DIRS is not set Guix home sets
    # XDG_DATA_DIRS="$HOME/.guix-home/profile/share:", which removes the
    # default "/usr/local/share:/usr/share" value.
    if [[ -z $XDG_DATA_DIRS ]]; then
        XDG_DATA_DIRS="/usr/local/share:/usr/share"
    fi

I have other more minor quibbles about how Guix Home handles XDG values:

XDG_STATE_HOME is set to a non-standard value.  In the current XDG Base
Directory Specification it defaults to "$HOME/.local/state", but Guix
Home sets it to "$HOME/.local/var/lib".  On a foreign distro this is
going to cause some disruption when a user switches to Guix Home, or
switches away.

XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
variable instead?  (if it ever does become a standard XDG variable, its
default may not be the same one picked by Guix Home, causing the same
issue as above).

Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to do
-- it is the job of whatever logs the user in.

XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their defaults
unnecessarily.

I modified my personal config by unsetting XDG_STATE_HOME, XDG_LOG_HOME,
XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_DATA_HOME if Guix Home left
them set to their default values (in the case of XDG_STATE_HOME I unset
it unconditionally).




Information forwarded to bug-guix <at> gnu.org:
bug#59474; Package guix. (Tue, 22 Nov 2022 07:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 59474 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>
To: 59474 <at> debbugs.gnu.org
Subject: Re: Guix Home generated .profile sets XDG_ vars that break
 GDM+Gnome login on foreign distros
Date: Tue, 22 Nov 2022 08:09:47 +0100
Am Montag, dem 21.11.2022 um 22:02 -0800 schrieb Matt Armstrong:
> The first thing I see is that $HOME/.guix-home/seutp-environment is
> modifying various XDG_ variables incorrectly.  It prepends new values
> without honor the variable's default value if it doesn't happen to be
> set already.
This is a known problem with Debian.  Unlike Ubuntu, which relies on
Flatpak and Snaps for its basic operations, Debian doesn't and hence
hasn't set up these variables explicitly.  Note that this isn't unique
to Guix Home or even just Guix.

> For example, if XDG_DATA_DIRS is not set its default value is
> "/usr/local/share/:/usr/share/".
None of these directories exist in Guix System.  Assuming them would be
a fault.  Note that the install script you're meant to use already
initializes these variables since July [1].

> XDG_STATE_HOME is set to a non-standard value.  In the current XDG
> Base Directory Specification it defaults to "$HOME/.local/state", but
> Guix Home sets it to "$HOME/.local/var/lib".
This is a genuine bug with Guix Home.

> XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
> should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
> variable instead?  (if it ever does become a standard XDG variable,
> its default may not be the same one picked by Guix Home, causing the
> same issue as above).
Another genuine bug with Guix Home, although the variable does predate
our support for XDG_STATE_HOME.  I suggest finding all uses of this
variable in Guix Home and replacing them accordingly.

> Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to
> do -- it is the job of whatever logs the user in.
I'm unsure about that one.

> XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their
> defaults unnecessarily.
Explicit is better than implicit.

Cheers


[1]
http://git.savannah.gnu.org/cgit/guix.git/commit/?id=23aafc800c9e678662766440916449ec5bbce830





Information forwarded to bug-guix <at> gnu.org:
bug#59474; Package guix. (Tue, 13 Dec 2022 05:23:01 GMT) Full text and rfc822 format available.

Message #11 received at 59474 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>,
 59474 <at> debbugs.gnu.org
Subject: Re: bug#59474: Guix Home generated .profile sets XDG_ vars that
 break GDM+Gnome login on foreign distros
Date: Tue, 13 Dec 2022 09:22:07 +0400
[Message part 1 (text/plain, inline)]
On 2022-11-22 08:09, Liliana Marie Prikler wrote:

> Am Montag, dem 21.11.2022 um 22:02 -0800 schrieb Matt Armstrong:
>> The first thing I see is that $HOME/.guix-home/seutp-environment is
>> modifying various XDG_ variables incorrectly.  It prepends new values
>> without honor the variable's default value if it doesn't happen to be
>> set already.
> This is a known problem with Debian.  Unlike Ubuntu, which relies on
> Flatpak and Snaps for its basic operations, Debian doesn't and hence
> hasn't set up these variables explicitly.  Note that this isn't unique
> to Guix Home or even just Guix.
>
>> For example, if XDG_DATA_DIRS is not set its default value is
>> "/usr/local/share/:/usr/share/".
> None of these directories exist in Guix System.  Assuming them would be
> a fault.  Note that the install script you're meant to use already
> initializes these variables since July [1].
>

I understand the inconvinience, but not sure that it has to be fixed on
Guix Home side.  According to the specification it's a fallback value
not a default value.

--8<---------------cut here---------------start------------->8---
If $XDG_DATA_DIRS is either not set or empty, a value equal to
/usr/local/share/:/usr/share/ should be used.
--8<---------------cut here---------------end--------------->8---

XDG_DATA_DIRS is not empty in our case and hence /usr/local/share and
/usr/share doesn't have to be used.  If it's critical for operation it
should be set before ~/.guix-home/setup-environment called, I would say
it looks like a debian bug, not Guix Home.  They same thing is true for
XDG_CONFIG_DIRS.

>> XDG_STATE_HOME is set to a non-standard value.  In the current XDG
>> Base Directory Specification it defaults to "$HOME/.local/state", but
>> Guix Home sets it to "$HOME/.local/var/lib".
> This is a genuine bug with Guix Home.
>
>> XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
>> should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
>> variable instead?  (if it ever does become a standard XDG variable,
>> its default may not be the same one picked by Guix Home, causing the
>> same issue as above).
> Another genuine bug with Guix Home, although the variable does predate
> our support for XDG_STATE_HOME.  I suggest finding all uses of this
> variable in Guix Home and replacing them accordingly.
>

XDG_STATE_HOME and XDG_LOG_HOME apppeared in Guix Home before they were
described in xdg base directory specification, so the values was picked
to mimic FHS.  Probably they should be adjusted to the values defined in
specification.

>> Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to
>> do -- it is the job of whatever logs the user in.
> I'm unsure about that one.
>

If it's set by elogind or whatever - cool, we will use value provided,
if not we explicitly set it, looks ok to me.

>> XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their
>> defaults unnecessarily.
> Explicit is better than implicit.
>
> Cheers
>
>
> [1]
> http://git.savannah.gnu.org/cgit/guix.git/commit/?id=23aafc800c9e678662766440916449ec5bbce830
>
>
>
>

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#59474; Package guix. (Tue, 02 May 2023 02:56:01 GMT) Full text and rfc822 format available.

Message #14 received at 59474 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Matt Armstrong <matt <at> rfc20.org>, 59474 <at> debbugs.gnu.org
Subject: Re: bug#59474: Guix Home generated .profile sets XDG_ vars that
 break GDM+Gnome login on foreign distros
Date: Tue, 02 May 2023 06:55:40 +0400
[Message part 1 (text/plain, inline)]
On 2022-11-21 22:02, Matt Armstrong wrote:

> I am experimenting with Guix Home on Debian Testing, using GDM+Gnome.
> The .profile generated by "guix home reconfigure" broke logging in to
> the Gnome desktop.  The gnome session would die, failing to initialize
> what it considered to be essential things, and return to the login
> screen I could log in to a tty, and was able to undo the new .profile
> and get back to a working system.
>
> The home-configuration.scm I used was generated by "guix home import"
> and was quite simple:
>
> ----------------------------------------------------------------------
> (use-modules (gnu home)
>              (gnu packages)
>              (gnu services)
>              (guix gexp)
>              (gnu home services shells))
>
> (home-environment
>   ;; Below is the list of packages that will show up in your
>   ;; Home profile, under ~/.guix-home/profile.
>   (packages (specifications->packages (list "glibc-locales")))
>
>   ;; Below is the list of Home services.  To search for available
>   ;; services, run 'guix home search KEYWORD' in a terminal.
>   (services
>    (list (service home-bash-service-type
>                   (home-bash-configuration
>                    (aliases '(("ls" . "ls --color=auto")))
>                    (bashrc (list (local-file ".bashrc" "bashrc")))
>                    (bash-logout (list (local-file ".bash_logout"
>                                                   "bash_logout"))))))))
> ----------------------------------------------------------------------
>
> Note: a stock GDM+Gnome setup runs the user's login shell when logging
> in via the GDM display manager, and this shell execs
> gnome-session-binary.  This doesn't necessarily happen with other
> display managers or other desktop environments, so on those systems the
> Guix Home .profile may not even run before the DE is initialized.
> Nearly all of my time debugging this was spent figuring this out!  :-)
>
> The .profile file generated by Guix Home is this:
>
> ----------------------------------------------------------------------
> HOME_ENVIRONMENT=$HOME/.guix-home
> . $HOME_ENVIRONMENT/setup-environment
> $HOME_ENVIRONMENT/on-first-login
> ----------------------------------------------------------------------
>
> The first thing I see is that $HOME/.guix-home/seutp-environment is
> modifying various XDG_ variables incorrectly.  It prepends new values
> without honor the variable's default value if it doesn't happen to be
> set already.
>
> For example, if XDG_DATA_DIRS is not set its default value is
> "/usr/local/share/:/usr/share/".
>
> But .guix-home/setup-environment will instead prepend a value without
> checking, leaving XDG_DATA_DIRS set incorrectly to
> "$HOME/.guix-home/profile/share:" when it should be
> "$HOME/.guix-home/profile/share:/usr/local/share/:/usr/share/".
>
> See this code in setup-environment:
>
> case $XDG_DATA_DIRS in
>   *$HOME_ENVIRONMENT/profile/share*) ;;
>   *) export XDG_DATA_DIRS=$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS ;;
> esac
>
> The correct idiom is this:
>
> XDG_DATA_DIRS=PATH_TO_PREPEND:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
>
> or
>
> XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}:PATH_TO_APPEND
>
> The above is what I see in various Nix and Snap configuration files.
>
> Because I have a few other things installed that modify XDG_DATA_DIRS
> before Guix Home does, Guix Home doesn't break that particular variable.
>
> It did break XDG_CONFIG_DIRS, since Guix Home was setting it to
> "$HOME/.guix-home/profile/etc/xdg:".  I worked around this problem by
> running this code before Guix Home's .profile:
>
>     # Note: when XDG_CONFIG_DIRS is not set Guix home sets
>     # XDG_CONFIG_DIRS="$HOME/.guix-home/profile/etc/xdg:", which removes
>     # the default "/etc/xdg" value.
>     if [[ -z $XDG_CONFIG_DIRS ]]; then
>         XDG_CONFIG_DIRS=/etc/xdg
>     fi
>
>     # Note: when XDG_DATA_DIRS is not set Guix home sets
>     # XDG_DATA_DIRS="$HOME/.guix-home/profile/share:", which removes the
>     # default "/usr/local/share:/usr/share" value.
>     if [[ -z $XDG_DATA_DIRS ]]; then
>         XDG_DATA_DIRS="/usr/local/share:/usr/share"
>     fi
>
> I have other more minor quibbles about how Guix Home handles XDG values:
>
> XDG_STATE_HOME is set to a non-standard value.  In the current XDG Base
> Directory Specification it defaults to "$HOME/.local/state", but Guix
> Home sets it to "$HOME/.local/var/lib".  On a foreign distro this is
> going to cause some disruption when a user switches to Guix Home, or
> switches away.
>
> XDG_LOG_HOME is a non-standard variable.  The spec suggests that logs
> should go in XDG_STATE_HOME.  Why not a establish a GUIX_LOG_HOME
> variable instead?  (if it ever does become a standard XDG variable, its
> default may not be the same one picked by Guix Home, causing the same
> issue as above).
>
> Setting XDG_RUNTIME_DIR is not something I would expect Guix Home to do
> -- it is the job of whatever logs the user in.
>
> XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME are set to their defaults
> unnecessarily.
>
> I modified my personal config by unsetting XDG_STATE_HOME, XDG_LOG_HOME,
> XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_DATA_HOME if Guix Home left
> them set to their default values (in the case of XDG_STATE_HOME I unset
> it unconditionally).

XDG_DATA_DIRS behavior seems reasonable, the problem should be reported
to Debian.  The work on STATE_HOME is happenning in a separate thread.
Closing this ticket.  Let us know if you have some other thoughts on the
topic.

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

bug closed, send any further explanations to 59474 <at> debbugs.gnu.org and Matt Armstrong <matt <at> rfc20.org> Request was from Andrew Tropin <andrew <at> trop.in> to control <at> debbugs.gnu.org. (Tue, 02 May 2023 02:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 30 May 2023 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 332 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.