Skip to content
How to Fix “zsh: command not found” & Repair Broken $PATH on MacMappleCare Community ↗

How to Fix “zsh: command not found” & Repair Broken $PATH on Mac

By Daniel Hayes • • 1 min read

Diagnostic Overview: What Broke Your Shell Path?

When macOS Terminal responds with zsh: command not found: brew (or even basic commands like ls or nano), your shell configuration file (~/.zshrc or ~/.zprofile) contains a syntax error that overwrote the default system $PATH instead of appending to it.

Step 1: Restore Temporary Access to Standard Commands

If basic commands like nano or cat fail, load the default system path manually in your current session:

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

Step 2: Inspect and Repair ~/.zshrc for Homebrew (Apple Silicon)

# Open your shell config in nano:
/usr/bin/nano ~/.zshrc

# Add the canonical Homebrew initialization block for Apple Silicon:
if [[ -f /opt/homebrew/bin/brew ]]; then
    eval "$(/opt/homebrew/bin/brew shellenv)"
fi

# Ensure standard user paths are properly exported:
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"

Step 3: Reload Your Environment

source ~/.zshrc
echo $PATH
Still running into this issue on your iPhone or Mac?

Share your OS version, device model, and exact error code in our independent peer Q&A rooms.

Ask in Community Forum →