Added `export` command in `.bashrc` to update PATH with binary location — GUI apps don’t know about update even though terminal does?

I had to add an:

export PATH="/path/to/my/bin:$PATH"

to my bash.rc, for progA‘s binary library location. Now, whenever I start a GNOME Terminal instance, I can type progA and hit return and the right binary is executed.

However, if I run progA through a GUI launched app, my system fumbles and doesn’t know where progA‘s bin is.

What should I do?

Answer

The ~/.bashrc file is only processed for interactive, non-login shells: probably a better place to set the path would be your ~/.profile

For maximum portability, you could follow the existing paradigm of the user’s ~/bin directory in ~/.profile (i.e. avoiding export, and testing for the directory’s existence): something like

if [ -d "/path/to/my/bin" ] ; then
    PATH="/path/to/my/bin:$PATH"
fi

Since ~/.profile is only read for login shells, you will need to log out and back in for it to take effect (or at least, start a new login shell e.g. using su - username). From there, the new PATH should propagate to all child shells – including the interactive, non-login shells of your gnome terminals.

Attribution
Source : Link , Question Author : Community , Answer Author : steeldriver

Leave a Comment