My system environment has been quite a mess this past month.
I used to put my environment variables in
~/.profile. However, the variables suddenly stopped being applied one day. I tried to switch my display manager from sddm, to gdm, then to lightdm, to no avail. I know
~/.profile, being essentially a bash script, is somewhat insecure;
~/.pam_environment is also probably the right way going forward, so I started moving variables into it.
I had a piece of code in my
~/.profile that checks Racket and Ruby's versions and sets the PATH to point to
gem's bin directory.
~/.pam_environment alone can't do that, so I wrote a Pollen version of the file and rendered / compiled it into the final
I then ask KDE to render the file everytime I log out.
It's really ugly, but it only has one job, which it does fine.
All seemed well, until a few days later my PATH config isn't taking effect anymore. For some reason, every other variable is properly set, just not PATH. Trying to see just exactly which file those variables came from, I noticed a variable that is only present in my
~/.pam_environment, telling me that it is indeed being read. I looked up info on PATH not being set with
.pam_environment, and found this StackExchange post hinting at something to do with the
var DEFAULT=value syntax.
pam_env's documentation on the config format, it seems that
DEFAULT is intended to be used for, well, defaults that could be overridden. Changing it into
OVERRIDE seems to tell
pam_env to just use the value and don't fiddle around.