MacOSX has a truly global path setting that precedes any other setting like ~/.bash_profile
.
The file /private/etc/paths
is a list of pathnames. The order from top to bottom defines the resulting order in the $PATH
variable.
After loading /private/etc/paths
there is a directory /private/etc/paths.d/
with files in the same style. Those are appended to the $PATH variable.
The default content of /private/etc/paths
looks like this:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
The resulting $PATH variable looks like this:
$ echo "$PATH"
# => "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
When using homebrew in its standard way, all your packages end up in /usr/local
.
This is a problem if you want to install software via homebrew that should replace system default installations.
Git is a good example.
The system default $ /usr/bin/git --version
outputs git version 1.7.4.4
.
Your homebrew installed git (at the time of writing) $ /usr/local/bin/git --version
outputs git version 1.7.8.3
.
But without changing the default path combination, you end up using system Git instead of homebrew Git.
There is various workarounds and fixes for this problem.
For example one could tackle this problem for a specific application. TextMate for example allows you to set TM_GIT
to a git executable of your choice. But why bothering with application specific settings, when you can fix the problem at its root.
Here are the contents of my corrected /private/etc/paths
. I've moved /usr/local/bin
on top.
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
I heard about this, going to give it a try. I still have trouble with paths and such in terminal, even if I adjusted in my bash_profile. Curious does this include after you put usr/local up top that when you do the which command it wil actually put to the correct item? Example which gcc; usually this will always point to usr/bin do to the fact homebrew has certain names for packages, and versions as well of packages. Example if I put gcc48 or what ever that is installed in usr/local it will than point to that one. I hate it when someone tries explaining something to me, and than asks just use which or echo $ . Everytime I know, it won't point to the item they are talking about unless I specify by the whole package name or version that is in usr/local.
alias python=python3
alias 2=python2.7
alias 3=python3
THAN had put this in my bash_profile:
this is comment out- Load .bash_aliases if it exists
test -f ~/.bash_aliases && source ~/.bash_aliases
now when I do, which python -It points to usr/local/bin Though I noticed if I do echo $python or even say python3 nothing happens.
This is what am understanding but don't know if is true or not. Please provide any input if you can on here or email me Richard.Shawn.Faust@gmail.com , Thanks!