I'm a longtime macports fan and occasional evangelist. It Just Works, installs in /opt/local with sudo, and very frequently installs binaries instead of needing to build. Homebrew is widely used and supported and pretty great, but I always feel just a little better about using macports instead and haven't had a reason to switch.
There are however occasional times where a package is not available on macports but is available on homebrew. I've always dreamed of having parallel installations, with zero drawback of homebrew (littering /user/local). I knew I could install in a different path instead of /user/local, but I still didn't quite trust that solution to cause zero problems for me. Today I had the obvious realization that I could solve this problem by installing in another user account. I am genuinely annoyed with myself for not thinking of this half a decade ago.
It was so easy! Here's how I did it.
- in System Preferences → Users & Groups, make a new non-admin user account named "homebrew"
- open a terminal and switch to that user with
sudo su - homebrew. run
whoami to double check you are operating as the homewbrew user.
follow the "Untar anywhere" instructions for installation. As of this writing these are:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"
a final piece that they don't mention is to do something like this so that the homebrew binary path is in your execution path when new shells start. you just need to do this once:
echo 'eval "$(homebrew/bin/brew shellenv)"' >> .zshrc
That's it! Now, when you want to install something with homebrew:
sudo su - homebrew
# ...inside the new shell
brew install my-cool-program
When you want to run a homebrew-installed program from your regular user account:
John Bachir's Code Blog