Use the Homebrew Package Manager on macOS

January 20, 2019

Homebrew is a package manager for macOS. It's extremely easy to install, and, once installed, allows you to manage both your core packages and your (non-App Store) applications easily through the command line.

Suppose you want to install Google Chrome on your Mac. To do this manually -- i.e., without Homebrew -- you need to:

  • find the website on which it lives
  • download the installer
  • run the installer
  • drag icons around, and set permissions
  • junk the installer

To install Google Chrome through Homebrew, you need to type brew cask install google-chrome.

That's it.

Install Homebrew on your Mac

Open a terminal window and run:


      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew tap caskroom/drivers

Use Homebrew to install command-line packages

You will now be able to install a variety of packages from the command line. For command-line packages, the installation format is brew install package. So, to install git, you’d run:


      brew install git

Popular packages include:

  • Zsh (zsh)
  • Composer (composer)
  • Node (node)
  • Wget (wget)
  • Bash (bash)
  • AWS-CLI (awscli)

You can find a full list of packages here, or generate a list by typing:


      brew search

Use Homebrew to install full macOS applications

Once you have installed all the command-line packages you need, you can move onto installing full macOS applications. For full applications, the installation format is brew cask install package. So, to install Google Chrome, you’d run:


      brew cask install google-chrome

There are more applications in the repository than you’d think, among them:

  • Google Chrome (google-chrome)
  • Dropbox (dropbox)
  • Google Backup and Sync (google-backup-and-sync)
  • Adobe Creative Cloud (adobe-creative-cloud)
  • Microsoft Office (microsoft-office)
  • Sonos Controller (sonos)
  • Zoom (zoomus)
  • Skype (skype)
  • Plex Media Server (plex-media-server)
  • Github Desktop (github)
  • AppZapper (appzapper)
  • Atom (atom)
  • Etcher (balenaetcher)
  • Visual Studio (visual-studio-code)
  • iTerm 2 (iterm2)
  • Signal (signal)
  • Sequel Pro (sequel-pro)
  • Handbrake (handbrake)
  • Vagrant (vagrant)
  • VLC (vlc)
  • Transmission (transmission)
  • Burn (burn)

To obtain a list of all the available applications, run:


      brew search --casks

Use Homebrew to update packages and applications

Over time, you will need to update the software that is managed by Homebrew. There are a number of ways to do this.

To find out which packages need updating, run:


      brew outdated

To update all installed packages, run:


      brew upgrade

To update a particular package, run brew upgrade package. For example, to upgrade git run:


      brew upgrade git

To ensure that Homebrew knows what is new and what is old, make sure that you sporadically update the index by running:


      brew update

For full applications, use the same formatting as above but add the word cask between brew and upgrade. e.g.:


      brew cask outdated
brew cask upgrade
brew cask upgrade google-chrome

Use Homebrew to remove packages and applications

To remove any packages you no longer want, you can use either brew uninstall package or brew remove package. These two commands do exactly the same thing.

To remove git, for example, you’d run:


      brew uninstall git

To remove full applications, just add the word cask between brew and uninstall. To remove Google Chrome, for example, you’d run:


      brew cask uninstall google-chrome

If you have multiple versions of a package installed and you want to uninstall all of them, add --force into the string. So, for example:


      brew uninstall --force git

If you are unsure which packages are installed on your machine, you can run:


      brew list

Obviously, to find out which full applications are installed on your machine, you’d add the word cask, so:


      brew cask list

Remove old versions of Homebrew packages

By default, Homebrew does not remove the old versions of upgraded packages; rather, it keeps them where they are, installs the new package in addition, and then links to the new package instead of the old one. Over time, this can begin to take up a good portion of your hard disk space. To force Homebrew to remove all old packages, run:


      brew cleanup

Find which version of Homebrew is installed


      brew -v

Versions

macOS: 10.14.3
Homebrew: 2.0
Notice an error?

Have we got something wrong? Please let us know and we’ll fix it right away.

Categories
Homebrew Mac macOS

Join the Discussion

Your email address will not be published. Required fields are marked *