My Linux terminal config files (.bash_profile, .profile, .bashrc) expand $PATH by prepending some custom directories. This only happens once (and I've also included some ENV vairiable based guards to enforce that it can only ever happen once). My .bash_profile
also sources the .rvm script (~/.rvm/scripts/rvm
) which prepends its own custom dirs. These RVM dirs must be first.
Everything's OK as long as I'm in a clean bash session.
If I run tmux
, however, the directory entries from my config files get prepended to PATH doubly (regardless of my ENV variable guards). It seems that tmux has two environments for ENV variables which it then merges.
This is a problem, since entries prepended by the .rvm script get only prepended once, and in the tmux scenario they don't end up first.
How can I prevent this from happening?
Edit—additional info:
All my PATH additions get prepended in .profile
, which I include from .bash_profile
(. ~/.profile
). All my GUI terminals are run "as a login shell".
In each config file, I use guards of the following form to prevent double inclusion:
if [ "$PROFILE_SOURCED" != "true" ]; then
export PROFILE_SOURCED=true
...
fi
By prepending an entry to PATH, I mean export PATH=entry:$PATH
.
.profile
is ignored if.bash_profile
exists and both are ignored when running non-login shells. Also see here for some tricks to make sure this does not happen. – terdon Apr 13 '14 at 15:02