Setup: Install Homebrew

Install Homebrew, the package manager you will use to install every other bootcamp tool on your Mac.

Novice · Operating System · Software Development · Updated

By

After this lesson you can

  • Install Homebrew and add it to your terminal's path
  • Check that a command-line tool is installed by asking for its version

macOS only. This is the first of eight Setup exercises. You need an internet connection and your Mac's login password.

Open the Terminal

Press Command+Space to open Spotlight, type Terminal, and press Return.

A window opens with a prompt, a line that ends in %. The prompt means the terminal is waiting for you to type a command. In these exercises, copy each command from its code block, paste it at the prompt, and press Return.

Install Homebrew

Paste this command and press Return:

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

The installer explains what it will do, then asks for your password. Nothing appears while you type a password in the terminal: no dots, no stars. That is normal. Type it and press Return.

When it asks you to press Return to continue, press it.

If your Mac does not have Apple's Command Line Tools yet, Homebrew installs them first. This can take 5 to 15 minutes. Let it finish.

Add Homebrew to your path

When the install finishes, read the end of the output. On a Mac with an Apple chip (M1 or later), it shows a Next steps section with commands to run. Run these three commands, one at a time:

echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

They tell your terminal where Homebrew lives, now and every time you open a new terminal window. A Mac with an Intel chip installs Homebrew in /usr/local, which is already on the path, so you can skip this step there.

Check your work

Close the Terminal window, open a new one, and run:

brew --version

You should see Homebrew followed by a version number. Then run:

brew doctor

You should see Your system is ready to brew. If brew doctor prints warnings instead, read them: most are advice, and the install still works.

Common problems

What you see What to do
zsh: command not found: brew Run the three commands from Add Homebrew to your path, then open a new terminal window.
The password prompt seems frozen It is waiting for your password. Type it (nothing appears) and press Return.
Need sudo access on macOS Your macOS account is not an administrator. Ask whoever manages the computer to make it one, or to install Homebrew for you.
The Command Line Tools install seems stuck Leave it running for 15 minutes. If a separate window asks to install them, click Install.