Terminal says zsh: command not found: brew just after you installed Homebrew.
Fastest fix: First check whether the installation finished and where brew is located. Then follow the installer’s instructions to configure your shell; don’t reinstall Homebrew or change system permissions as your first move.
This guide is for students who have just installed Homebrew and can’t run brew in the macOS terminal.
It’s also for beginners following a programming course on a Mac, a school-managed computer, or a remote Mac.
If your issue is that the installer stopped with an error, start with the installation-status checks below.
Check whether the installation finished
A terminal’s “command not found” message means that the current shell couldn’t find a command under the names and locations it searches. It doesn’t, by itself, prove that Homebrew is missing. Homebrew’s official installation instructions include post-installation steps for setting up the shell. If those steps were skipped, the files may be installed while your terminal still can’t find brew.
Start with what you can see, not by running the installer again. Look for the final messages from the installation attempt. Did it report that installation completed and show follow-up shell commands, or did it stop with an error? Copy the full message into your notes. The last few lines often distinguish an incomplete install from a completed install with a configuration step left to do.
| What you see | What it suggests | What to do next |
|---|---|---|
| The installer stopped with an error before its completion message | Installation may not have finished | Record the full error and check the Homebrew troubleshooting guide before trying again |
| The installer reported completion and displayed shell setup instructions | Homebrew may be installed, but the shell setup may be missing | Check the command and the actual installation location |
The installer completed, and brew worked earlier in the same terminal |
The current session may have changed, or another shell configuration may be in use | Check which shell and startup file apply to the terminal you opened |
Don’t run a second installation just because the command isn’t recognized. A second attempt won’t necessarily repair a missing shell configuration, and it can make it harder to tell which installation or prefix your terminal is using. Homebrew’s guidance on common issues, including multiple installations and path problems is useful if you discover more than one possible brew.
Test the command before changing configuration
Open the terminal where you saw the error and try these checks:
brew --version
command -v brew
echo "$SHELL"
The first command asks Homebrew to print its version. The second asks your current shell to show the location of a brew command it can find. The third prints the shell recorded in the SHELL environment variable. These commands inspect the current session; they don’t reinstall software or change permissions.
If brew --version prints a version and command -v brew prints a path, the shell can find Homebrew now. If the first command fails and the second prints nothing, the shell hasn’t found brew by its current search rules. That points to either an installation-location issue or a shell setup issue. It does not tell you which one yet.
The Homebrew command reference documents brew commands and brew shellenv. In plain terms, PATH is the list of locations your shell checks when you type a command. If Homebrew’s command directory isn’t included in the active shell’s search setup, typing brew alone won’t reach it.
| Check | Example result | What it tells you |
|---|---|---|
brew --version |
A Homebrew version appears | brew is available to this session |
command -v brew |
A path appears | The shell resolved the command to that location |
echo "$SHELL" |
A shell path appears | A clue about your configured shell; confirm the shell actually running in the terminal |
For the shell identity, don’t rely on guesswork alone. macOS Terminal can use a configured default shell, and Apple explains how to change the default shell. If you use another terminal app or a school-provided setup, check its settings and instructions too.
Confirm the actual Homebrew prefix
A prefix is the main directory where Homebrew places its files. The default depends on the Mac’s processor type: Homebrew documents /opt/homebrew as the default prefix for Apple Silicon Macs and /usr/local for Intel Macs in its FAQ about installation locations.
| Mac or setup | Homebrew default prefix | Important limitation |
|---|---|---|
| Apple Silicon Mac | /opt/homebrew |
Confirm this against your installer output and actual files |
| Intel Mac | /usr/local |
A custom setup or managed device may differ |
| Custom or school-managed setup | No universal path to assume | Use the installation output or ask the administrator |
These are documented defaults, not proof of where Homebrew is installed on your machine. You may have used a custom setup, or the computer may have been prepared by a school or administrator. Use the installation output first. Don’t copy a path from a tutorial simply because it matches a different Mac.
If you have a candidate prefix from the installer, test for the executable using that exact location. For example, only if the installer identifies /opt/homebrew as your prefix, run:
/opt/homebrew/bin/brew --version
For an installer that identifies /usr/local, use:
/usr/local/bin/brew --version
The default-prefix information above comes from Homebrew’s FAQ; these example commands use those documented defaults and the documented brew executable location. If neither command matches your actual installation, don’t keep trying random directories. Return to the installer output or check with the person who manages the Mac.
Pause before editing: Don’t paste a shell script from a forum, overwrite your whole shell configuration file, or use administrator privileges to get past a school restriction. Confirm the installation prefix and the shell file you actually use first.
Fix the shell configuration for your setup
A shell is the program that reads and runs commands in a terminal. Its configuration file supplies settings when a shell session starts. Homebrew’s installer tells you which setup to apply; its installation guide’s post-installation steps explain how to add brew shellenv for the actual prefix.
Use the installer’s instructions as the source of truth. For an installation at /opt/homebrew, the documented setup commonly uses:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
For an installation at /usr/local, substitute the prefix only if that is the location confirmed for your installation:
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
These examples write a line to ~/.zprofile; they aren’t universal instructions for every shell, terminal, or managed Mac. The correct file depends on your active setup. Follow the post-installation command shown by your installer and Homebrew’s official instructions. Don’t replace the whole file with a copied example.
| Your situation | Safer next action | Avoid |
|---|---|---|
| The installer printed a shell setup command | Use that command and its confirmed prefix | Replacing its path with a guessed default |
| The terminal’s shell and the setup file are unclear | Check terminal settings and the official shell guidance | Editing several startup files at random |
| The Mac is managed by a school | Ask the administrator if settings are locked | Trying to bypass restrictions or expand your privileges |
If you’re unsure which startup file applies, inspect the terminal’s shell settings and compare them with the installer’s instructions. Apple’s Terminal guide describes using Terminal. If a course handout or school configuration specifies a particular shell, follow that before changing anything.
Open a fresh terminal and verify the fix
A configuration change may not affect a terminal window that was already open. Quit or close that terminal window, open a new session, and run:
brew --version
command -v brew
If the version appears and the command path points to the Homebrew installation you confirmed, the new session can find brew. You can now continue with your course’s next instruction.
If it still fails, go back through the checks in order:
- Installation status: Did the installer finish, or did it stop with an error?
- Actual location: Does the executable exist at the prefix shown by the installer?
- Active shell: Is the terminal using the shell you expected?
- Startup file: Did you add the official setup to the file that applies to that shell?
- New session: Did you fully open a fresh terminal after changing the configuration?
Use the Homebrew troubleshooting guide linked above if these checks don’t resolve the problem. If the Mac is managed by your school and you can’t edit the necessary settings, stop there and contact its administrator. A permission restriction is not a reason to run an unfamiliar command with elevated access.
Use this decision rule:
- If the installer did not finish, investigate its specific error before changing shell settings.
- If the installer finished and the executable works by its confirmed full path, follow the installer’s shell configuration instructions.
- If a fresh terminal still cannot find the command, recheck the active shell, startup file, and actual prefix rather than reinstalling blindly.
- If the computer blocks the required change, ask its administrator instead of bypassing the restriction.
Check your course environment before choosing another Mac
If you’re learning Python or following a course that uses Homebrew, first verify the course’s actual requirements. A missing brew command may be a small shell configuration issue; it doesn’t automatically mean you need a different computer. Try the commands from the course only after you’ve confirmed that the terminal recognizes Homebrew.
If your current device cannot run the required macOS tools, or school rules prevent you from configuring a suitable environment, a remote Mac may be worth considering for a course project or a temporary practice period. Check that the access method supports the terminal work you need, and test your own course instructions rather than assuming every tool or setup will behave the same way. You can review the available MACCOME remote Mac option and compare it with your course requirements before deciding.
Choose the next step based on the cause
A local Mac is the simplest choice when you already have one and can make the required configuration changes. It keeps your work on your own computer, but it won’t help if the course requires tools your device cannot run or your school locks the relevant settings.
A remote Mac can give you access to a Mac environment without changing your school computer. It depends on a reliable network connection, and it may not fit tasks that need a physical device or a long-running, heavily used machine. If you’re only trying to finish a short course exercise, compare the setup effort and access conditions with the value of using it.
A Windows-only workaround can still be suitable for many programming exercises, but it does not make the local Windows terminal recognize a Mac installation of Homebrew. If your assignment specifically depends on macOS tools, an environment that can actually run those tools is the relevant requirement. Before you choose, check the course instructions, your device permissions, and whether the task needs a local physical connection.
If the problem is only a missing shell setting, fix that first using Homebrew’s official instructions. If you need a temporary Mac environment because your current device can’t meet the course requirements, renting a remote Mac through MACCOME may provide a more suitable place to complete and verify that work. For long-term, sustained workloads or tasks requiring a physical interface, compare a personally owned Mac and other approved options instead.