How to install Homebrew on macOS – Full guide (2021) | RJS

How to install Homebrew on macOS – Full guide (2021)

Ralph J. Smit Laravel & PHP-developer.

Homebrew is a great way to manage packages on macOS. Arguably it is one of the best package managers out there, because it's simple to use and offers thousands – if not more – packages with just a few simple commands. In this guide I'll show you how to install Homebrew on macOS, so that you can get up and running immediately.

Homebrew is an app that works via the terminal. That means that there isn't a native 'regular' UI like you would expect (checkout Cakebrew if you do need one). Installing Homebrew can be daunting if you do it for the first time, but, in fact, it's nothing more than running a few commands in the right order.

Installing Xcode command line tools

In order to install Homebrew, you need the Xcode command line tools installed. If you've never made use of the terminal yet on your Mac, chances are that this need to be installed. Paste the following command in the terminal to install them:

xcode-select --install

If the command line tools are not yet installed, a popup will appear, asking you for permission to install the tools. Click Install and wait till the installation is finished.

If the tools are already installed, the terminal will display a message that it is already installed and that updates come the Software Updates.

Install Homebrew on MacOS

To install Homebrew, open up the terminal and paste the following command:

/bin/bash -c "$(curl -fsSL"

This command will start the installation for you. Enter your password to start the process (if asked). The installation will continue automatically. The installation is successful if you see something like this:

* [new branch] master -> origin/master
HEAD is now at 7fb6354a2a pandoc-crossref: update bottle.
Warning: /opt/homebrew/bin is not in your PATH.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
No analytics data has been sent yet (or will be during this `install` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
==> Next steps:
- Add Homebrew to your PATH in /Users/ralphjsmit/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/ralphjsmit/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run `brew help` to get started
- Further documentation:

Final steps: put /opt/homebrew/bin in your $PATH

After Homebrew is installed, you'll still need to take a few final steps. The first step is to put a specific path in your $PATH. You do not need to know why this is, but Homebrew will provide you with two commands that will do the trick:

==> Next steps:
- Add Homebrew to your PATH in /Users/ralphjsmit/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/ralphjsmit/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Copy the two commands from your terminal (they're a slightly different for each computer), paste them and hit enter. Note that the first command starts with echo... up to .../.zprofile and the second is eval " ... shellenv)".

Disabling analytics (optional)

The last step I usually take is disabling analytics. Homebrew uses Google Analytics to send 'anonymous aggregate user behaviour analytics' to them. This allows them to prioritize bugfixes and check which OS version people are using (useful for development).

You're free to enable or disable Homebrew analytics. It will not impact your experience. Opting out (forever) can be done by running:

brew analytics off

Published by Ralph J. Smit on in Guides. Last updated on 10 March 2022.

Hey!👋 Like what you read?

Every now and then I send out a newsletter with new articles, tutorials and packages, mainly related to PHP in general and Laravel.

Subscribe to the newsletter and stay up to date with all things Laravel, Tailwind, WordPress & PHP. Never miss an update.🙋‍