TL;DR something changing my path, triplicating my custom directories even when commenting out the export PATH= line from bashrc

Recently I added a line to my .bashrc to add two custom directories to the path:

export PATH=~/Documents/Code/Own/Scripts/:~/Misc/Applications/phantomjs-2.1.1-linux-x86_64/bin:$PATH

All looks fine, no problems. Today, however, I checked my path to see which directories I had and discovered the custom directories were there three times:

echo $PATH

Strange, I thought to myself. I'll comment out the line from my bashrc - it must be being sourced three times for some reason. Open a new tab in the terminal - the first pair of custom directories is gone but the other two are still there:


So, maybe this is just a problem with GNOME Terminal saving the path with each session. Logged in through a TTY and the path was correct - no dupe entries (my bashrc was still sourced via a line bash_profile). However, using xterm the problem was still present - meaning it's not down to something with GNOME terminal.

What I don't understand is what file is changing the path when I've commented out the line from the bashrc and never added it anywhere else. Any ideas?

closed as off-topic by Jeff Schaller, techraf, GAD3R, HalosGhost, Anthon Oct 7 '16 at 4:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, techraf, GAD3R, HalosGhost, Anthon
If this question can be reworded to fit the rules in the help center, please edit the question.


If you open a new tab in GNOME terminal, it copies the environment to the new shell rather than creating a new empty environment. Personally I think that's a mistake (and it's one of the reasons why I won't use GNOME terminal myself) but I'm sure the developers have their reasons. After starting a new tab and copying the environment, it then starts your shell, which goes through its normal interactive startup routine, which involves sourcing .bashrc

If you want to avoid your addition being done several times, you have a few options:

  • switch to a different terminal emulator
  • don't do the modification in .bashrc, but instead in .bash_profile, which is part of the login procedure rather than the interactive startup and therefore shouldn't be used on a new tab (but obviously it's possible that GNOME terminal is even more broken than I thought and it might still start the shell in a way that sources .bash_profile, after all; it's been quite a while since I last used it)
  • check whether the PATH variable already contains the needed modification before making it again.

Fixed by logging out and in again, so it must've been caused by something I did earlier in my session.

Not the answer you're looking for? Browse other questions tagged or ask your own question.