Setting PATH with environment.d does not work on debian
rumpelsepp opened this issue · comments
Submission type
- Bug report
Request for enhancement (RFE)
systemd version the issue has been seen with
233; debian version: 233-10
Used distribution
Debian Testing
In case of bug report: Expected behaviour you didn't see
I have this content in my ~/.config/environment.d/99-defaults.conf
:
GOPATH=$HOME/Go
PATH1=$GOPATH/bin:$HOME/.cargo/bin:$HOME/.local/bin:$PATH
PATH=$GOPATH/bin:$HOME/.cargo/bin:$HOME/.local/bin:$PATH
After a login in gnome3 I expect to see $PATH
and $PATH1
to be equal;; with expanded $GOPATH
prepended.
In case of bug report: Unexpected behaviour you saw
On a shell I get this instead:
$ printenv PATH PATH1 GOPATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
/home/stefan/Go/bin:/home/stefan/.cargo/bin:/home/stefan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/home/stefan/Go
$ systemctl --user show-environment
...
GOPATH=/home/stefan/Go
PATH1=/home/stefan/Go/bin:/home/stefan/.cargo/bin:/home/stefan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/u
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
...
In case of bug report: Steps to reproduce the problem
Create that file from above, relogin to gnome, open a terminal and type printenv
.
$PATH
seems to be hardcoded somewhere which overwrites my setting; important fact: I use gnome on wayland. So I have no shellscripts that are being exectued during login.
Maybe it's debian specific. I close this until we know.
As requested from bugs.debian, I reopened this.
/cc @keszybz
I am also seeing this problem on Debian Buster (GNOME 3.22, systemd v234) when using a GNOME Wayland session. I am not yet entirely sure what's causing this, but I currently suspect the following:
This is a bug where people complained that since Wayland doesn't run the session through a login shell, some of the configuration files used by login shells (~/.profile
, ~/.bash_profile
, etc.) are obviously not read anymore.
https://git.gnome.org/browse/gnome-session/commit/?id=5e36cd63e71520f829bbd77c102b64179e08992a
This was the fix for the bug mentioned above, it comes down to running the login shell in gnome-session if Wayland is used.
https://git.gnome.org/browse/gnome-session/tree/gnome-session/gnome-session.in
This is the current version of the gnome-session
shell script. There are some changes, but it seems the scripts still tries to launch a login shell to restore the expected behaviour on Wayland.
This is what Debian installs in /etc/profile
per default. As you can see, this will statically set PATH to a value depending on the effective UID.
As I said, I haven't tracked this down entirely, but I wanted to share my preliminary findings here.
@rumpelsepp What is the output of running /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator
? It prints correctly for me. Also, what is the output of systemctl --user show-environment
?
The generator itsellf prints the environment correctly. The output of the other command is listed in the original post.
@AlexanderKurtz nailed it. It is indeed a debian problem.
The relevant commit in gnome is this: https://git.gnome.org/browse/gnome-session/commit/gnome-session/gnome-session.in?id=7e307f8ddb91db5d4051c4c792519a660ba67f35
So, in gnome wayland there is a login shell which sources the well known files in order to set up environment variables and do some initialization stuff. The debian provided /etc/profile
overwrites my environment.d settings. My personal fix is, to write my environment definitions in ~/.profile
. To sum up, not a systemd problem AFAIC.
OK, closing then. Thanks for tracking this down.
I think this might be caused by this gdm bug (on GNOME 3.36): https://gitlab.gnome.org/GNOME/gdm/-/issues/385