Environment Variables on Second Login

Running openSUSE LEAP 15.2 with GNOME (and Systemd), I have noticed the following behavior:
[li]On the first GNOME login after boot, the shell configures itself as I would expect, including the proper values in the PATH environment value.[/li][ul]
[li]By this, I mean that the PATH variable includes $HOME/bin, and this reflects in any terminal session I would open. [/li][/ul]

[li]During this first boot session, I run some daemon-like processes for the user.[/li][ul]
[li]At times, I have set KillUserProcesses=no in the Logind configuration (/etc/systemd/logind.conf) [/li][li]Other times, I have used User-specific Systemd Units [/li][/ul]

[li]I log out of this GNOME session, then some time later log back in, and find that the new shell does not have the proper values in the PATH environment variable[/li][ul]
[li]The variable does not contain $HOME/bin, but instead has the value:[/li]```

[li]Digging around, I discovered that this is the [i]PATH[/i] value for the [i]gdm[/i] user, for the Display Manager Login prompt session [/li][/ul]
[li]If I log out, and then kill all of the processes for the user I was using, the system loads the environment correctly again.[/li][ul]
[li]Until I kill all of the processes,  from the initial login, the user has a Systemd parent process for all of the running processes, even after logout [/li][/ul]
I have observed this behavior as far back as LEAP 15.0, and although I can't remember definitely, I am thinking that I did not encounter this behavior before that.

In summary, with long-running user processes, on initial login, I have the correct environment, but on subsequent logins, I have the environment from GDM.

How can I troubleshoot this and fix this the right way*?

*: What is the “right way”?

If this is actually a bug, then I file a bug report and live with it until someone fixes it.

I would like to avoid just adding additional lines to /etc/bash.bashrc.local or /etc/profile to overwrite the incorrect values. I would rather configure my system and run my processes in such a way that they work with the pieces I am using in a holistic way.

I don’t see this.

However, the “systemd --user” process is a parent to the entire process tree. So its environment is inherited.

It probably has an environment variable saying that startup scripts (from “/etc/bashrc” have already been run and should not be run again. And that’s why path is not being set as you expect.

The reason that I don’t see this, is that my own shell startup scripts set the path that I want.


Where are you defining your PATH environment variable?

  • In ‘~/.profile’ or, ‘~/.bashrc’?
    *=2]Please be aware that, currently, openSUSE reads ‘~/.bashrc’ via ‘/etc/profile’ –
    if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
        # loop detection
        readonly _HOMEBASHRC=true
        test -r $HOME/.bashrc && . $HOME/.bashrc

Which ever way you do it, the graphical session should be reading ‘~/.profile’ once during the user’s login and, it should be using the environment variables defined in ‘~/.profile’ in all processes initiated by that graphical session.

  • Immediately following the PATH environment variable declaration in ‘~/.profile’, do you have an “export PATH
    ” statement?

The tip in the report about clearing the PROFILEREAD variable in /etc/environment seems to suffice as a workaround for now: