Homebrew is a great package manager for OSX and one of the easiest ways to install Unix tools and open source software (Homebrew most certainly isn’t the only package manager out there: other popular choices: Macports and Fink but Homebrew is my personal favorite).
In order to install Homebrew you need XCode and the respective command lines tools. Xcode is available in the AppStore
Download and Install Xcode. You have to run it once and agree to the license. It will automatically start installing the components. Grab a cup of coffee/tea it will take a few minutes even on a fast machine with a SSD.
Open up a Terminal and issue the following command to install the command line tools
Before you can download and run the script to install Homebrew you have to temporarily disable the System Integrity Protection of OSX in order to write to the /usr folder and create the installation root directory /usr/local.
If you encounter any permissions issues the following article provides instructions to fix the permissions problem. In case you upgraded an existing installation to El Capitan the /usr/local folder will most probably exist already and you will only have to issue the following command to fix the permission problem:
sudo chown -R $(whoami):admin /usr/local
If it’s a fresh installation (wiped the hard drive or simply bought a new Mac) /usr/local will not exist and you have to manually create the folder.
- Reboot into recovery mode (Hold CMD + R on boot) → Utilities → Terminal
- Temporarily disable SIP:
- Reboot back into OSX
- Open the Terminal application and issue the following command:
sudo mkdir /usr/local && sudo chflags norestricted /usr/local && sudo chown -R $(whoami):admin /usr/local
The command creates the installation directory for Homebrew and removes the directory flags that restrict access to it when SIP is re-enabled.
Reboot back into recovery mode and issue the following command to reenable SIP protection:
Reboot back into OSX and now you will be able to write to /usr/local and install Homebrew by starting the following script in a Terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After completion of the installation check for any outstanding issues as suggested at the end of the setup by issuing the following command:
A short list of commands for Homebrew, refer to the man page for more information:
To search for an application:
brew search <search_keyword>
To install an application:
brew install <application_name>
To list all applications installed by homebrew:
To remove an installed application:
brew remove <application_name>
To update Homebrew:
Homebrew’s default installation directory:
This ensures that Homebrew doesn’t interfere with Unix utilities shipped by OSX (e.g. if you install python3 via Homebrew it will not interfere with the Version shipped with OSX)