How to Install Homebrew on Mac

December 12, 2024

Introduction

Homebrew is a package manager for macOS and Linux that allows applications to be installed via the command line. It provides a practical way to set up, update, or remove software on macOS, which does not have a native CLI package manager.

In this tutorial, learn how to install and use Homebrew on macOS with examples.

How to install Homebrew on Mac.

Prerequisites

  • A system running macOS Big Sur or newer.
  • Administrative privileges.

How to Install Homebrew on Mac

Setting up Homebrew on macOS involves installing Xcode Command Line Tools and running the Homebrew installation script. The following sections explain the installation and post-installation procedure and show how to manage Homebrew formulae (i.e., software packages).

Follow the steps below to install Homebrew on Mac.

Install Xcode Command Line Tools

Xcode is an integrated development environment for macOS containing command-line tools Homebrew needs to function properly.

Note: Xcode is a prerequisite for many other tools on macOS, such as PuTTY, a telnet and SSH client.

Proceed with the steps below to install Xcode Command line tools:

1. Run the following command in Terminal:

xcode-select --install

Note: View a comprehensive list of Mac terminal commands for quick refrence when working in macOS terminal. The article also includes a downloadable PDF cheat sheet.

2. Click Install when prompted to proceed with the installation.

Installation prompt for XCode Tools.

The script displays the Xcode License Agreement.

3. Click Agree and wait for the installation to finish.

Install Homebrew

With Xcode Command Line Tools on the system, enter the following command to run the Homebrew installation script:

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

Enter the administrator password when prompted and press Enter to continue.

Install Homebrew on macOS.

The message appears to confirm the installation was successful.

Homebrew installation script completes successfully.

Note: If you do not like Homebrew, try Pip, another package manager available on Mac. See how to install Pip on Mac.

Turn Off Analytics

By default, Homebrew collects the following system information:

  • The Homebrew user agent.
  • Google Analytics version.
  • Homebrew analytics tracking ID and Homebrew analytics user ID.
  • Events (for example, the Homebrew install event category).

Enter the following command to disable the analytic data collection:

brew analytics off

The command produces no output. Check the analytics status by typing:

brew analytics

The output shows the analytics have been disabled.

Check if Homebrew collects analytical data on your Mac.

Install, Update, or Remove Packages

Homebrew features a simple syntax that facilitates package management on macOS.

Use the following command to install a formula using Homebrew:

brew install [package name]

For example, enter the following to install the tree command:

brew install tree
Install an app using Homebrew.

The command updates the Homebrew formula list and installs the tree command.

To update a specific formula, type:

brew update [package name]

Enter the following command to check if any formulae need updating:

brew upgrade

On a fresh Homebrew installation, the output shows everything is up to date.

Updating Homebrew on macOS.

Remove a formula from the system with the following syntax:

brew uninstall [package name]

For example, enter the command below to uninstall the tree formula:

brew uninstall tree
Uninstall an app using Homebrew.

Installing Desktop Applications

Homebrew casks allow the package manager to install GUI applications. For example, install the Firefox browser by adding the --cask flag:

brew install --cask firefox

Visit the Homebrew website for the full list of available casks.

How to Uninstall Homebrew on Mac

Remove Homebrew from the system by running the following command:

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

When prompted, type y and press Enter to uninstall Homebrew.

Uninstall Homebrew from your Mac.

Common Homebrew Commands

The following table lists some of the most used commands when working with Homebrew.

CommandDescription
brew install [formula]Installs a new formula.
brew updateUpdates Homebrew itself to the latest version.
brew upgradeUpgrades all outdated formulae.
brew search [query]Searches for formulae matching the given query.
brew info [formula]Displays detailed information about a specific formula.
brew uninstall [formula]Uninstalls a specific formula.
brew install --cask [cask]Installs a Cask (for GUI applications).
brew doctorChecks for and tries to fix common problems with the Homebrew installation.
brew cleanupRemoves old or unnecessary files related to Homebrew.

Conclusion

After following the steps in this tutorial, you should have a working Homebrew installation on your system. The article also provided a brief introduction to managing packages using Homebrew.

For the Linux tutorial, read How to Install Homebrew in Linux.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Install Puppet on macOS
April 1, 2021

Puppet is an open-source administrative engine that lets you perform remote admin tasks in a network through a single master node.
Read more
How to Install and Get started with Git on Mac
September 12, 2024

Git is a version control system that allows developers to track a project and actively contribute without interfering in each other’s work. Learn how to install Git, with four different installation approaches.
Read more
How to Install Node.js and NPM on Mac
July 31, 2024

Node.js is a popular back-end JavaScript runtime used for creating web servers and scalable network apps. NPM is a package manager for JavaScript and the default package manager for Node.js. See how to install them on Mac.
Read more
How to install SQL Server on MacOS
July 13, 2021

Microsoft's SQL Server 2019 supports Windows 10, Linux, macOS, and Docker as install options. This tutorial takes you through the process of installing SQL Server on macOS as a Docker deployment.
Read more