PATH and graphical sessions

3 réponses [Dernière contribution]
Avron

I am a translator!

Hors ligne
A rejoint: 08/18/2020

In a plasma (KDE) wayland session opened right after boot, I have:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

If I open a GNOME wayland session, close it and open a plasma wayland session again:

echo $PATH
/home/david/.local/bin:/home/david/bin:/home/david/.guix-profile/bin:/home/david/.config/guix/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Opening a GNOME wayland session is so fast that I can't measure the time it takes (whereas plasma takes about 25 seconds to start!) so it isn't a terrible burden to open and close a GNOME wayland session first to get the right PATH, but I wonder whether there is a way without doing that.

Besides, the more I open and close sessions the longer PATH becomes, with many things there repeated, for example:

echo $PATH
/home/david/.local/bin:/home/david/bin:/home/david/.guix-profile/bin:/home/david/.config/guix/current/bin:/home/david/.local/bin:/home/david/bin:/home/david/.guix-profile/bin:/home/david/.config/guix/current/bin:/home/david/.local/bin:/home/david/bin:/home/david/.guix-profile/bin:/home/david/.config/guix/current/bin:/home/david/.local/bin:/home/david/bin:/home/david/.guix-profile/bin:/home/david/.config/guix/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

I never tried tweaking the PATH variable so this is coming from things automatically installed.

I see that my .profile is adding ~/bin et ~/.local/bin but for some reason it wasn't executed when I started a plasma wayland session. I believe that /etc/profile.d/guix.sh is what sets the pathes for guix, so it also wasn't executed.

I don't know how to check what triggers the execution of the files in /etc/profile/ and ~/.profile, and I am surprised that the contents of PATH set in previous sessions persists in another session, it looks like a bug.

Avron

I am a translator!

Hors ligne
A rejoint: 08/18/2020

I added my .bashrc, .profile and the whole contents of /etc/profile, which I guess is what is relevant to this (I had it prepared and selected but I tend to forget that having the file selected is not enough, one needs to click on the "attach" button).

Pièce jointeTaille
init.tar.gz 2.41 Ko
Magic Banana

I am a member!

I am a translator!

En ligne
A rejoint: 07/24/2010

I personally use GNU Bash (by default in Trisquel) and add the $HOME/Travail/bin directory to PATH with that line in ~/.bashrc:
PATH="$HOME/Travail/bin:$PATH"

Avron

I am a translator!

Hors ligne
A rejoint: 08/18/2020

I could do that but when opening a session in a number of graphical environments, everything is set properly in PATH already, including for programs installed by guix.

Besides, when the PATH is not set for guix, XDG_DATA_DIRS (and other variables) is also not set for guix, and also not for flatpak. I see that /etc/profile.d/guix.sh is setting everything properly for guix, and there is also /etc/profile.d/flatpak.sh setting XDG_DATA_DIRS for flatpak, and there are other .sh files in /etc/profile.d/ for other things, and when PATH is not only what is in /etc/environment (seems to be the system default), all the variables are set according to all files in /etc/profile.d.

So it looks like either /etc/profile is not sourced in some cases, or it is but something fails at some point so that at least guix.sh and flatpak.sh are not executed, or could there be another reason?

When the PATH (and other variables are not set), apps installed by guix are not visible in the menus of KDE, but apps installed by flatpak are visible still. I don't know how KDE does to create its menus, whether flatpak apps do something for them to persist even when the environment is not fully set.