4

echo $PATH provides:

/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin

while /etc/environment states

PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

I though the environment file is responsible for setting the PATH environment. I mean the file is called environment, and the only commend therein is path. What am I missing?

This is Ubuntu 18.04.1 and when I try to run pcsxr, it tells me /usr/games is not added to environment variable. This seems true from one point of view and false from another point of view. There is no problem with the desktop file, it has been validated. Also that game in question has been validated to be at /usr/games

Running this command:

$ grep --color -H 'PATH=' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
                    ~/.bash_aliases /etc/bash.bashrc /etc/profile \
                     /etc/profile.d/* /etc/environment 2> /dev/null

/home/neonred811/.profile:    PATH="$HOME/bin:$PATH"
/home/neonred811/.profile:    PATH="$HOME/.local/bin:$PATH"
/etc/environment:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
abu_bua
  • 11,313
Uranium
  • 41

2 Answers2

1

I had the same problem while trying to set my JAVA_HOME environment variable (link) after installing the default-jdk apt package, also on Ubuntu 18.04.1.

Setting JAVA_HOME in /etc/environment didn't work at all, even though that file is symlinked in /usr/lib/environment.d/ as described here.

Setting it in ~/.profile did work, but was obviously not system-wide, so some tools couldn't see it and it was just a pain.

I ended up setting it using a script in /etc/profile.d/ as described here, and that finally worked.

I have no idea why /etc/environment isn't working. I've successfully used that method on Ubuntu 16.04, but no luck on 18.04. I also grepped everything in /etc/ as described in this related question and also suggested here, but couldn't get to the bottom of it.

maltem-za
  • 111
0

You can grep everything to find out where /usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin is being set:

time sudo grep -rnw \
--exclude-dir={boot,dev,lib,media,mnt,proc,root,run,sys,/tmp,tmpfs,var} '/' -e \
"/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin"

This will take a few minutes to run so make some coffee or take out the garbage. On an NVMe SSD though it will take 45 seconds and show this:

Binary file /home/rick/.mozilla/firefox/9fu0cuql.default/places.sqlite matches
Binary file /home/rick/.mozilla/firefox/9fu0cuql.default/places.sqlite-wal matches

real    0m46.343s
user    0m13.143s
sys     0m8.853s

On my system the only place where the path is overridden like yours is by Firefox.

However my $PATH variable is always normal (for me):

$ echo $PATH
/home/rick/bin:/home/rick/.local/bin:/mnt/e/bin:/mnt/e/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin