Homebrew

Package manager for macOS

Official Page

Table of contents
  1. Installation
    1. Opt-out of Homebrew analytics
  2. Useful commands
    1. brew search
    2. brew install
    3. brew uninstall
    4. brew list
    5. brew deps
    6. brew info
    7. brew update
    8. brew upgrade
    9. brew doctor
    10. brew autoremove
  3. Installing other versions of Casks
  4. Notes
    1. keg-only

Installation

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then follow the instructions.

In my case, I had to add /opt/homebrew/bin to PATH.

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/hombrew/bin/brew shellenv)"  # Or just open a new tab

Opt-out of Homebrew analytics

brew analytics off

Useful commands

brew search ${package}

brew install

brew install ${package}
brew install --cask ${package}

cask is an extension to Hombrew formulae, mainly for GUI applications

brew uninstall

brew uninstall ${package}

brew uninstall won’t let you remove a package if it is a dependency of another package. You could force uninstall, but you generally don’t wanna do this.

brew list

brew list
brew list --versions

brew deps

brew deps ${package}
brew deps --installed
brew deps --installed --tree

Shows dependencies.

brew info

brew info ${package}

Shows a summary of information of a formula/cask.

Summary includes dependencies, current stable version, install status, etc.

brew update

brew update

Updates brew itself.

brew upgrade

brew upgrade  # Upgrade all
brew upgrade ${package}

Upgrades installed packages that are outdated.

brew doctor

brew doctor

Diagnoses problems or errors regarding, but not limited to, brew.

Possible warnings or errors may include, interruption during brew install, failure to symlink binary, deprecated Xcode, etc.

brew autoremove

brew autoremove

This removes dangling dependencies that were not removed with the parent package.


Installing other versions of Casks

If you want to install an older version of a cask,

brew tap homebrew/cask-versions

Then search for the version you want.

brew search ${package}

Notes

keg-only

By default, brew installed binaries are symlinked to /usr/local/bin, but keg-only formulae are not. This is usually due to the preexistence of an older OS shipped default version, typically in /usr/bin.

Although not symlinked in /usr/local/bin, keg-only or not, every brew formula is kept in /usr/local/Cellar and every formula is symlinked in /usr/local/opt.

Which means you can add /usr/local/opt/<formula>/bin to PATH (just making sure it goes in the front of /usr/bin so that it is found first).

All of the information here can be found during install or brew info Caveats.


Table of contents