zsh: command not found: claude (Fix for macOS and Linux)

Fix "zsh: command not found: claude" with practical steps for Homebrew, npm global install, PATH export, shell reload, and verification on macOS and Linux.

March 7, 2026 · 1 min read

TL;DR

Fastest Fix Path

Install Claude CLI, ensure its bin directory is on PATH, reload zsh, then verify with command -v claudeand claude --version.

If you hit apply/edit reliability issues after install, use Morph Fast Apply for deterministic file updates.

2-5 min
Typical fix time
3
Main root causes
1 min
Reading time

Extracted keywords

commandclaude

Symptoms

Terminal output

$ claude
zsh: command not found: claude

This error means your shell cannot locate a claude binary in directories listed in PATH.

Troubleshooting decision tree

Follow this exact branch order

Start
├─ Run: command -v claude
│  ├─ Found path? -> Run: claude --version
│  │  ├─ Works -> Done
│  │  └─ Fails -> Reinstall (Homebrew or npm), then re-verify
│  └─ Not found
│     ├─ Run: brew list | rg -E '^claude(-code)?$'
│     │  ├─ Installed -> Export brew bin to PATH + reload shell
│     │  └─ Not installed
│     │     ├─ Install via Homebrew OR npm
│     │     └─ Export PATH + reload shell + hash -r
└─ Run final checks: which -a claude && claude --version

Not installed

Install Claude CLI first via Homebrew or npm, then verify command discovery.

Installed but missing on PATH

Add brew/npm global bin directory to PATH in ~/.zshrc and reload your shell.

PATH updated but still failing

Clear command cache (hash -r), open a fresh terminal, and re-run verification commands.

Multiple installations conflict

Use which -a claude to inspect precedence and remove stale binaries from old locations.

Fix 1: Homebrew install (macOS/Linux)

Install and wire Homebrew path

brew update
brew search claude
brew install claude-code

# Persist brew shell environment for zsh
# Apple Silicon default: /opt/homebrew
# Intel macOS default: /usr/local
# Linuxbrew default: /home/linuxbrew/.linuxbrew

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

command -v claude
claude --version

brew shellenv is the safest cross-machine way to put the correct Homebrew bin directory on PATH.

Fix 2: npm global install

Install Claude CLI package

npm install -g @anthropic-ai/claude-code

# Find npm global prefix/bin
NPM_PREFIX="$(npm config get prefix)"
echo "$NPM_PREFIX"
ls "$NPM_PREFIX/bin" | rg '^claude$'

Export npm global bin in zsh

NPM_PREFIX="$(npm config get prefix)"
echo "export PATH="$NPM_PREFIX/bin:$PATH"" >> ~/.zshrc
source ~/.zshrc
hash -r

command -v claude
claude --version

Fix 3: PATH export for macOS/Linux shells

Inspect and debug PATH

echo "$PATH" | tr ':' '
'
which -a claude

# If Homebrew binary exists but isn't found:
BREW_PREFIX="$(brew --prefix)"
echo "export PATH="$BREW_PREFIX/bin:$PATH"" >> ~/.zshrc

# If npm binary exists but isn't found:
NPM_PREFIX="$(npm config get prefix)"
echo "export PATH="$NPM_PREFIX/bin:$PATH"" >> ~/.zshrc

Put persistent exports in ~/.zshrc (interactive shells) and keep ~/.zprofile for login-time setup likebrew shellenv.

Reload shell and verify

Reload sequence

# zsh
source ~/.zshrc
hash -r
exec zsh

# bash (if you use bash instead of zsh)
source ~/.bashrc
hash -r
exec bash

# or open a new terminal tab/window

Verification commands

command -v claude
which -a claude
claude --version

# Optional: check linked binary target
ls -l "$(command -v claude)"

If command -v claude prints a path andclaude --version exits successfully, your setup is fixed.

FAQ

Why does it work in one terminal but not another?

One session loaded updated dotfiles while another did not. Reload both, or start a fresh terminal after modifying ~/.zshrc.

Should I edit ~/.zprofile or ~/.zshrc?

Use ~/.zprofile for login initialization (likebrew shellenv) and ~/.zshrc for interactive PATH exports.

How do I avoid old binary conflicts?

Run which -a claude, keep the expected path first, and remove stale installations you no longer use.

Need deterministic code updates after CLI setup?

Use Morph Fast Apply through the OpenAI-compatible API for fast, semantic code merges.