Homebrew is a package manager for Mac, which installs useful things that Apple forgot.


Homebrew requires Apple’s Command Line Developer tools. When you update macOS, Apple screws them up every time. You’ll probably get this error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

See xcode-select to fix that.

If you’re still reading, follow the Homebrew install instructions.


brew update


Managing packages

# Show installed packages
brew list -l

# Install a package
brew install {packageName}

# Show outdated packages
brew outdated

# Upgrade all packages
brew upgrade

# Upgrade a package
brew upgrade {packageName}

# Uninstall a package
brew uninstall {packageName}

# Show package info (like where it's installed)
brew info {packageName}

Cleaning up

# Remove all old packages
brew cleanup

# Remove all old packages (dry run)
brew cleanup -n

# Remove old symlinks
brew prune

Installed packages

  • php@5.6
  • php@7.1


Switch PHP version

You have to edit your .zshrc shell profile.

Totally remove and reinstall package

Updating the PHP package may not remove old php.ini files, which breaks things. You have to remove them manually.

Fixing unlinked packages

When installing a packages, Homebrow might be unable to create symlinks into /usr/local/sbin. This is required so packages are available in the shell’s PATH variable.

# Check which packages are not symlinked properly:
brew doctor

# Check if the `/usr/local/sbin` directory exists:
cd /usr/local/sbin

# If not, create the directory:
cd /usr/local
mkdir sbin

# Change permissions so the directory is writeable by the system:
sudo chown -R `whoami`:admin /usr/local/sbin

# Link the packages:
brew link {packageName}