How to install Homebrew on macOS

Harjot Singh
3 min readNov 20, 2023

--

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 as you would expect

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.

Step 0: Installing Xcode command line tools

In order to install Homebrew, you need the Xcode command line tools 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 from the Software Updates.

Step 1: Install Homebrew on macOS

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

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

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:

From https://github.com/Homebrew/homebrew-core
* [new branch] master -> origin/master
HEAD is now at 7fb6354a2a pandoc-crossref: update 0.3.11.0 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:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

==> Next steps:
- Add Homebrew to your PATH in /Users/harjotse/.zprofile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/harjotse/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh

Step 2or Final step: 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:

1st command->

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/harjotse/.zprofile
2nd command->

eval "$(/opt/homebrew/bin/brew shellenv)"

Note:-

Where in a command there is ‘harjotse’ written just simply replace it with the user name that shows when you open your terminal.

Copy the two commands(shown in step 3) from your terminal (they’re slightly different for each computer), paste them, and hit enter.

Disabling analytics (optional)

The last step I usually take is disabling analytics. Homebrew uses Google Analytics to send ‘anonymous aggregate user behavior analytics’ to them. This allows them to prioritize bug fixes 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

--

--

Harjot Singh
Harjot Singh

Written by Harjot Singh

Just an ordinary guy who like to code | SDE by Profession and Passion | Full stack Developer | Open to collab, for freelance work just a DM away 😄

No responses yet