"zsh: command not found" on a Mac means the shell cannot locate the program you typed. The fix is almost always one of three things: the tool is not installed, its install location is not on your PATH, or the command name is misspelled. Work through the checks below in order and you will normally resolve it in a few minutes.

What You'll Need

  • Your Mac and an account that can open Terminal (Applications > Utilities > Terminal).
  • The exact command you were trying to run, including capitalisation.
  • Your administrator password if a tool needs installing.
  • A working internet connection for package installs.

Step-by-Step

  1. Confirm the spelling and case. macOS commands are case-sensitive. Python and python are different names, and a stray space or a smart quote pasted from a website will also fail. Retype the command by hand once.
  2. Check whether the tool is installed at all. Run which -a yourcommand. If it prints nothing, the program is not on your PATH and may not be installed. If it prints a path, the program exists and the problem is elsewhere.
  3. Look in the usual install folders. Homebrew on Apple silicon installs into /opt/homebrew/bin; on Intel Macs it is /usr/local/bin. Run ls /opt/homebrew/bin or ls /usr/local/bin and look for your command. If it is there, jump to step 5.
  4. Install the tool if it is missing. The safest route is the official installer from the vendor's own site, or Homebrew if you already use it: brew install packagename. Only use official sources; avoid random scripts from forums.
  5. Check your PATH. Run echo $PATH. The folder that holds your command must appear in that colon-separated list. If it does not, open your shell config file with nano ~/.zshrc and add a line such as export PATH="/opt/homebrew/bin:$PATH" (use /usr/local/bin on Intel Macs). Save with Control-O, Enter, then Control-X.
  6. Reload the shell configuration. Run source ~/.zshrc, or simply close the Terminal window and open a new one. Then retry your command.
  7. Check for a broken Homebrew install. If brew itself is not found, run the official Homebrew install command from brew.sh, then run brew doctor and follow its advice.
  8. Verify the fix. Run which yourcommand again. A path should now print, and the original command should run.

Menu and file names can differ slightly between macOS versions, so if a label does not match exactly, look for the closest equivalent.

Common Mistakes

  • Editing the wrong file. zsh reads ~/.zshrc, not ~/.bash_profile. Changes in the bash file will not affect a zsh session.
  • Using the wrong Homebrew path. Apple silicon Macs use /opt/homebrew/bin; Intel Macs use /usr/local/bin. Mixing them up leaves the command unfound.
  • Forgetting to reload. Editing ~/.zshrc does nothing in the current window until you run source ~/.zshrc or open a new terminal.
  • Overwriting PATH. Writing export PATH="/some/folder" without :$PATH wipes the rest of your PATH and breaks other commands.
  • Pasting smart quotes. Curly quotes from a web page are not valid shell syntax and produce confusing errors.
  • Installing with sudo when not needed. Package managers and language tools generally should not be run with sudo; doing so can create permission problems later.

Tips

  • Use which -a rather than plain which to see every copy of a command on your PATH.
  • Press Tab while typing a command to let zsh complete it; if nothing completes, the name is likely wrong or missing.
  • Keep PATH additions at the end of ~/.zshrc so they load after any defaults.
  • If you use several language tools, prefer their official version managers rather than editing PATH by hand for each one.
  • Run brew doctor after any Homebrew change; it catches most path and permission issues early.

Troubleshooting

The command works in one Terminal window but not another. One window was opened before your config change. Open a fresh window or run source ~/.zshrc.

PATH looks correct but the command still fails. Check the file is executable with ls -l /path/to/command. If permissions look wrong, reinstall the tool through its official installer rather than changing permissions by hand.

You see a "permission denied" error instead of "command not found". That is a different problem: the file exists but cannot be run. Reinstalling from the official source is safer than altering ownership or permissions.

Homebrew commands fail after a macOS upgrade. Reinstall the Homebrew command-line tools using the official instructions at brew.sh, then run brew doctor.

Nothing you try works. Open a new Terminal window, run echo $SHELL to confirm you are in zsh, and compare your ~/.zshrc against a backup. As a last resort, rename the file to ~/.zshrc.bak, open a new terminal, and rebuild your PATH lines one at a time. This does not delete your files, but it does remove custom settings, so keep the backup.

Frequently Asked Questions

Why does zsh say command not found when the app is installed?

The app's folder is probably not on your PATH. Add the correct Homebrew or install folder to ~/.zshrc and reload the shell.

Should I edit .zshrc or .zprofile?

For PATH changes that should apply to every terminal, ~/.zshrc is the usual place. ~/.zprofile runs at login; either can work, but pick one and stay consistent.

Is it safe to run sudo to fix this?

Usually not needed. sudo will not make a missing program appear and can create ownership problems. Install the tool properly instead.

How do I undo a PATH change?

Open ~/.zshrc, remove or comment out the line you added (put # at the start), then run source ~/.zshrc.

Why does the command work in bash but not zsh?

Bash and zsh read different config files. Your PATH line is probably in ~/.bash_profile; copy it into ~/.zshrc.

Do I need to restart my Mac?

No. Opening a new Terminal window is enough to reload the shell configuration.