Macports inserts /opt/local/bin/ ahead of /usr/bin in the path, and so if the same program exists in both folders, the Macports-installed one takes precedence.

I'm unclear on how Homebrew manages this issue. Taking a concrete example, say I run brew install git, I now have

> /usr/local/bin/git --version
git version 2.14.2
> git --version
git version 2.13.5 (Apple Git-94)

To use the more recent (git 2.14), it's tedious to use /usr/local/bin/git. Also, giving more priority to /usr/local/bin on my own may have undesirable side effects.

What's the standard way to run updated Homebrew programs when they collide with ones already on macOS? For python I've seen that Homebrew avoids collisions by requiring users to type either python2 or python3. This is less clear for the case of git.


General convention is in fact to put /usr/local/bin ahead of /usr/bin. This is doable via editing the /etc/path file or sudo launchctl config user path "/usr/local/bin:$PATH". This will cause executables in /usr/bin to be shadowed by the ones in /usr/local/bin. The Homebrew FAQ suggests this.

Homebrew recipes will deliberately not link any programs into /usr/local/bin that could potentially cause system-wide conflicts (homebrew executables are actually installed in /usr/local/Cellar and symlinked to /usr/local/bin). When you install a potentially conflict-causing package, homebrew will warn you about it, and say something to the effect of "We didn't automatically link this package. If you really want to, you can run `brew link ..." Homebrew is generally pretty good about being respectful of existing system packages.

As an empirical anecdote, I have always shadowed /usr/bin with /usr/local/bin and have never run into any issues. YMMV, of course.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .