macOS Brew

Brew or Homebrew is a package manager. Similar to Gentoo's emerge, or Ubuntu's apt.

What does it do?

Homebrew installs stuff you need that Apple didn’t. Install packages to their own directory and then symlinks their files into /usr/local. Packages are called formulae and repositories are called taps.

Installing brew:

Open Terminal and type:

/usr/bin/ruby -e "$(curl -fsSL"

Searching packages

To search for a specific package type:

brew search STRING

To search keywords only in the package's description:

brew desc -s STRING

Or to search both, package names and the description:

brew desc -d STRING 

Installing / Removing packages

brew install PACKAGE_NAME

brew remove PACKAGE_NAME    

Updating package list and packages

Packages change all the time. To make sure the list of packages and their versions is updated run this:

brew update

List outdated packages:

brew outdated

Upgrade all outdated packages:

brew upgrade

Preventing Upgrade:

To prevent a specific package from upgrading when you issue a brew upgrade you can "pin" it with:

brew pin PACKAGE

Or unpin it with:

brew unpin PACKAGE

Linking / Unlinking packages:

Usually not needed, but sometime is so... ;)

To link, that is, create symlinks to the package's binaries in the $PATH:

brew link PACKAGE

And to unlink the package:

brew unlink PACKAGE

Removing dead symlinks from the Homebrew prefix:

brew prune


List all installed packages:

brew list

List installed packages that are not dependencies of another installed package:

brew leaves

List package's dependencies:

brew deps PACKAGE

List package's dependancies as a tree:

brew deps --tree PACKAGE

Taps (repositories) Add / Remove / List

Link repository:

brew tap TAP/NAME

Unlink repository:

brew untap TAP/NAME

List all linked taps:

brew taps   

rmtree command (external)

It's an external command for Homebrew that provides a new command, rmtree, that will uninstall that formula, and uninstall any of its dependencies that have no formula left installed that depend on them.

Tap this repository and install via brew itself.

brew tap beeftornado/rmtree

More help:

Removing "lost" packages

Currently, Homebrew doesn’t have any kind of feature like apt’s autoremove to remove unused dependencies — brew doesn’t make a distinction between packages explicitly installed by the user and those installed as dependencies.

Luckily for all of us Connor Worley has written a script that iterates through all packages that aren’t being depended on and asks if you want to keep or remove them.

It depends on fish shell, so install it first:

brew install fish

The script:

#!/usr/bin/env fish

set -l visited_formulas 'brew-cask'

function check_formulas
 for formula in $argv
    set -l dependees (brew uses --installed $formula)
   if [ -z "$dependees" ]; and \
      not contains $formula $visited_formulas 
        read -p "echo \"$formula is not depended on by other formulas. Remove? [Y/n] \"" -l input
       set visited_formulas $visited_formulas $formula
       if [ "$input" = "Y" ]
         brew remove $formula
          check_formulas (brew deps --1 --installed $formula)

echo "Searching for formulas not depended on by other formulas..."

check_formulas (brew list)

Checking Build Options

You can check the options/flags the install will be done with by issuing this command:

brew options fish

Editing Build Options

If you need to install the package with different options you can try to edit the config file for it:

brew edit fish


Removes any older versions and deletes old downloads from the Homebrew download-cache:

brew cleanup

Check for brew errors

brew doctor

Brew config

Show Homebrew and system configuration useful for debugging.

brew config

GUI Tool

As far as I know there is only one GUI frontend for brew, it's called Cakebrew. You can download it here:


More help

{{ message }}

{{ 'Comments are closed.' | trans }}