Duplicate paths in $PATH environment variable

Asked

Viewed 91 times

0

I have noticed that the paths I add to $PATH in my .bashrc duplicates appear when I open tmux (multiplexer terminal):

export PATH=$HOME/miniconda3/bin:$PATH
export PATH=$PATH:$HOME/Devel/bin

If I print $PATH in a session of tmux he appears as follows:

/home/alejandro/miniconda3/bin:/home/alejandro/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/alejandro/Devel/bin:/home/alejandro/Devel/bin

Out of tmux he appears normal:

/home/alejandro/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/alejandro/Devel/bin

I suspect it has to do with the first line of my .bash_profile:

if [[ -f ~/.bashrc ]]; then . ~/.bashrc; fi

If I comment on this line (which I don’t quite understand its function), the $PATH appears correct inside and outside the tmux, only that I miss the customization of the script prompt bash-git-prompt within the session of tmux. Apparently tmux accesses the script of bash-git-prompt by means of .bash_profile.

For now the solution I found was:

  • comment on the first line of bash_profile;
  • copy lines from .bashrc about the bash-git-prompt script within the .bash_profile (now those lines are in the two files).

With that, the $PATH appears correctly inside and outside the tmux and the same thing with prompt.

My question is whether it’s right or whether there’s another, more correct way to do it.

Edited:

.bash_profile

.bashrc

  • The line you said you didn’t know what you do interprets the file . bashrc, if it exists in the current user’s home directory. You made these exports in more than one place? Or play . bashrc more than once? If not, consider posting the . bashrc and . bash_profile files along with your question.

  • @Genos, added the files as requested.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.