PATH env var set in systemd is not imported (but NOT_PATH is)
Fedora 28 Workstation gdm-3.28.2-1.fc28.x86_64
-
Create
~/.config/environment.d/path.conf
as follows:PATH=/nowhere:$PATH NOT_PATH=$PATH
-
Run
systemctl --user daemon-reload
-
Log out of GNOME and log back in again
-
gnome-terminal
-
env | grep PATH
Expected results: PATH is shown as containing /nowhere
Actual results: PATH is not shown as containing /nowhere (but NOT_PATH is).
Setting environment variables in the users systemd instance was supposed to be the "proper fix", that would avoid the need to run a shell (~/.profile) when launching a GUI session. And this approach mostly works ok inside GNOME... but it doesn't work for PATH, one of the very common variables people want to set.
This is due to gdm-{wayland,x}-session. They use this line
g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
The FALSE here means that we do not set an environment variable if it already existed.
I think changing this to TRUE wouldn't work on it's own. Some tweak would also be needed to the handling of session_variables
- i.e. otherwise, the old stale DISPLAY value would overwrite the current one...
ISTM, that DISPLAY and friends need to be flushed out of the systemd environment anyway, so we could do that before we import from it :). (Unsetting them on a clean logout also sounds like a good idea, I don't know if that's already been implemented).