I have a MacOSX system that I've been using for a number of years, and during this time, I have installed quite a few packages via Macports.

I now want to try Homebrew, but it's clear from what I've read here and elsewhere that the default installations of Homebrew and Macports cannot easily coexist.

It is not a viable option for me to uninstall Macports, since so much of my daily MacOSX work involves using various Macports-installed utilities. Furthermore, many of my own, homegrown utilities are now interdependent with Macports. And finally, a lot of executables and shared libraries that I routinely use are now installed under /usr/local, and my system would quickly become unusable if I cleared out that directory tree.

So my question is this: has anyone come up with an alternate way to install Homebrew which can coexist with Macports? Specifically, has anyone figured out how to make Homebrew utilize a directory tree such as /usr/local/homebrew instead of /usr/local?

Thanks in advance for any suggestions or pointers to docs.

  • If you just want to try, why not set up an OS X virtual machine? It's not against Apple's TOS for OS X 10.7 and you can experiment with whatever you want there. Even if it kind of works to use both in parallel, I wouldn't be surprised if things started breaking...
    – Daniel Beck
    Jan 28, 2012 at 21:11
  • Thank you very much, but I prefer to get both package managers running in the same OSX environment, if there is any way at all to do that. This is because if I like Homebrew, I will then want to gradually install packages via that system and gradually uninstall the old Macports-based packages. Unfortunately, it isn't a viable alternative for me to decide on Homebrew, blow away all my legacy Macports code in one fell swoop, and then struggle to replace it all in another fell swoop via Homebrew.
    – HippoMan
    Jan 28, 2012 at 21:15

2 Answers 2


You can tell Homebrew to use its own directory, and then add that to the path. Although not for the same purpose, this excerpt from the installation guide tells it:

Multiple installations

Create a Homebrew installation wherever you extract the tarball. Whichever brew command is called is where the packages will be installed. You can use this as you see fit, e.g. a system set of libs in /usr/local and tweaked formulae for development in ~/homebrew

Source: https://github.com/mxcl/homebrew/wiki/installation

  • Thank you Karolos. I'm not encouraged by the following statment on that same wiki page: "However do yourself a favor and install to /usr/local ... Pick another prefix at your peril!" But I'll give this a try and report back later.
    – HippoMan
    Jan 29, 2012 at 12:48
  • I have tried to install homebrew in /usr/local/homebrew. However, a number of packages that I try to install are failing. When I run /usr/local/homebrew/bin/brew doctor, I get references to literally dozens of unexpected dylibs, static libraries, .pc files, and .la files, plus warnings about certain packages requiring a /usr/local installation. Since my system won't run at all if I blow away my legacy software installations (which is where most of those "unexpected" files are coming from), it looks like there is no way for me to use homebrew on my system. Oh well ... (sigh) ...
    – HippoMan
    Jan 29, 2012 at 13:30
  • @HippoMan: Sorry that it doesn't work out. One question though: is /usr/local/homebrew correctly set up in your paths? i.e. PATH and (DY)LD_LIBRARY_PATH
    – Karolos
    Jan 29, 2012 at 14:10
  • @HippoMan: Which packages are failing ? I just tried install a couple of them and didn't see any problem (after editing /etc/paths to add /usr/local/homebrew/bin).
    – Karolos
    Jan 29, 2012 at 14:23
  • Yes, I have PATH and LD_LIBRARY_PATH set up correctly to point to bin and lib under the /usr/local/homebrew tree. One of the packages that failed is gawk, which is a prerequisite for avidemux. But I will restart from scratch and try one more time, in case I made some sort of error.
    – HippoMan
    Jan 29, 2012 at 14:50

My way to force them coexist is to make MacPorts not visible by default, but visible when invoking any MacPorts programs. That is, wrap MacPorts programs with some script like:

if [ "$#" -le 0 ]; then
  echo "Usage: $0 command [arg1, arg2, ...]" >&2
  exit 1
if [[ -z $MACPORTS_PREFIX ]]; then
exec $command $* 

If you name this script as macports.sh, you can do the wrapping by macports.sh macports_bin, such as macports.sh port will run port wrapped.

For convenience, you can put macports.sh something into some scripts with the same name as the commands themselves and put them in your HOME directory, such as ~/bin, ~/.local/bin, etc.

I've written a blog post about this one month ago. You can read it if you need a look into the details.

You must log in to answer this question.

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