1

When I run env it shows 3 times /usr/bin under PATH. Same for every path under PATH title.
For example - my scala bin directory shows 3 times.

However, in my .bash_profile, it is written just one time. Also its not in .bashrc also. I need to make these 3 occurrences to 1, as even though I remove some path under PATH in .bash_profile, it still shows 2 times, which means that path is still set.

echo $PATH shows the same thing.

And, if it matters, I am using Mac OSX.

3

Duplicate paths won't hurt anything.

There likely is a script somewhere that is overwriting the path variable. Try the following to narrow down where the variable is being set.

See if there is an environment variable overwriting the path
logout + log back in

echo $PATH

See if a fresh shell has the same path set

sudo su foo -  
echo $PATH

See if sudo with an initial login has the path set

sudo su foo -i   
echo $PATH

Sounds like you have already checked your ~/.bashrc and ~/.bash_profile Check if there are any scripts in /etc/profile

2

OK..So I found the solution.
Here is what I was doing :-
1) vi ~/.bash_profile
2) make changes
3) source ~/.bash_profile to see those changes in effect .

It seems for every editing and subsequent source command, temporarily keeps in current session.
So , if i made changes 3 times and consequent source command, it shows 3 times the same path if i do echo $PATH or env. Closing the terminal and restarting it puts back everything to normal.

So, it was just a matter or restarting the terminal!!

Clarification :- Different platforms may perform differently. I found macosx-10.7 works this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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