Troubleshooting

zsh: command not found: claude — install Claude Code and fix PATH

zsh/bash: command not found: claude means Claude Code isn't installed, or ~/.local/bin isn't on PATH. Anthropic's install command and the permanent PATH fix.

Published ~8 min read

Short answer: zsh: command not found: claude (or bash: claude: command not found on Linux, 'claude' is not recognized... on Windows) means either Claude Code is not installed yet, or it is installed but its folder is not on your shell’s PATH. Anthropic’s own recommended fix is the native installer, which puts the binary at ~/.local/bin/claude:

macOS · Linux · WSL
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell
irm https://claude.ai/install.ps1 | iex

Open a new terminal window afterwards — the one you installed from keeps its old PATH — and check:

any shell
claude --version

Everything below is checked against Anthropic’s own setup and troubleshooting documentation for Claude Code.

Which message are you seeing?

MessagePlatformMeaning
zsh: command not found: claudemacOS Terminal (zsh is the default shell)No install found on this shell's PATH
bash: claude: command not foundLinux, including a fresh VPSThe same
'claude' is not recognized as an internal or external commandWindows CMDThe same, CMD's wording
claude : The term 'claude' is not recognized as the name of a cmdletWindows PowerShellThe same, PowerShell's wording

In every case the fix is the same: install it, or fix the PATH. Work out which.

Install Claude Code

Anthropic’s recommended method is the native installer — it installs a standalone binary (not a Node.js script) and updates itself automatically in the background:

macOS · Linux · WSL
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell
irm https://claude.ai/install.ps1 | iex
Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Three other install methods exist, and each has its own PATH behaviour:

MethodCommandAuto-updates?
Native installer (recommended)curl -fsSL https://claude.ai/install.sh | bashYes, in the background
Homebrew (macOS)brew install --cask claude-codeNo — run brew upgrade --cask claude-code
WinGet (Windows)winget install Anthropic.ClaudeCodeNo — run winget upgrade Anthropic.ClaudeCode
npm (global package)npm install -g @anthropic-ai/claude-codeNo — run npm install -g @anthropic-ai/claude-code@latest
apt / dnf / apk (Linux)sudo apt install claude-codeNo — through your normal system upgrade

npm installs require Node.js 22 or later. On an older Node, npm prints an EBADENGINE warning but still finishes the install, and claude still runs, because the npm package only pulls down a native binary through a per-platform optional dependency — it does not run under Node at all once installed.

“Installed but still not found”: fix the PATH

The native installer places the binary at ~/.local/bin/claude on macOS and Linux, or %USERPROFILE%\.local\bin\claude.exe on Windows, and tells you in its own output when that folder is missing from PATH — a line starting Native installation exists but ~/.local/bin is not in your PATH. If you missed that line, or the folder was dropped from PATH afterwards, this is the fix.

First: is it actually there?

macOS · Linux
ls -la ~/.local/bin/claude
Windows PowerShell
Test-Path "$env:USERPROFILE\.local\bin\claude.exe"

No such file or directory (or False) means there is no native install — install it with the command above. A listing (or True) means the binary exists and the problem is PATH; continue below.

Then: is that folder on your PATH?

macOS · Linux
echo $PATH | tr ':' '\n' | grep -Fx "$HOME/.local/bin"

A printed path means it is already there — something else is wrong; see conflicting installs below. No output at all means it is missing, and here is the permanent fix, two commands for your shell:

zsh (~/.zshrc) — macOS default
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
bash (~/.bashrc) — most Linux distributions
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

On macOS specifically, Terminal starts Bash as a login shell, which never reads ~/.bashrc on its own — it reads the first of ~/.bash_profile, ~/.bash_login or ~/.profile that exists. If you use Bash rather than zsh on a Mac, put the line in ~/.bash_profile instead (or whichever of the three already exists), not ~/.bashrc.

Symptom after adding the PATH lineCause
Still not found in the same windowThat terminal was already open and keeps its old PATH — open a new window, or quit and reopen a terminal inside an editor
grep -n '.local/bin' ~/.zshrc prints nothingThe echo didn't save — rerun the two commands
echo $0 shows a different shell than you editedThe line went into the wrong file — run the matching pair for that shell instead

On Windows PowerShell, add the directory to your user PATH permanently rather than with $env:PATH alone, which only lasts for the current window:

Windows PowerShell
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')

Restart your terminal afterwards, then confirm:

any shell
claude --version

Several installs fighting each other

claude can come from three places at once on the same machine: the native installer at ~/.local/bin/claude, a legacy local install at ~/.claude/local/ left behind by an older version of Claude Code, and a global npm install. If PATH finds the wrong one first, you get an old version or odd behaviour rather than “not found.” List every claude your shell can see:

macOS · Linux
which -a claude
npm -g ls @anthropic-ai/claude-code 2>/dev/null
Windows PowerShell
where.exe claude

Anthropic’s own recommendation is to keep only the native install and remove the others:

remove a global npm install
npm uninstall -g @anthropic-ai/claude-code
remove the legacy local install
rm -rf ~/.claude/local

On Windows: “Claude Code requires Git for Windows or PowerShell”

Git for Windows is optional, not required — Claude Code falls back to the PowerShell tool when it cannot find Git Bash, so this message means neither was found at all. Installing Git for Windows with “Add to PATH” selected fixes it; if PowerShell itself is missing from PATH, its default location is C:\Windows\System32\WindowsPowerShell\v1.0\.

On Alpine Linux

Alpine and other musl-based distributions do not ship bash or curl by default, so the standard install command fails with a bare not found. Install them first, along with the runtime libraries Claude Code needs there:

Alpine
apk add bash curl libgcc libstdc++ ripgrep

If ripgrep is missing from Alpine’s main repository for your version, Anthropic’s docs point at the community repository; after adding it and running apk update, set USE_BUILTIN_RIPGREP=0 in settings.json under env.

Confirm it, for good

any shell
claude --version
claude doctor

claude --version prints a version string such as 2.1.211 (Claude Code). claude doctor runs a fuller, read-only diagnostic — install health, settings-file errors, update status — without starting a session, and is the fastest way to seewhy something is off once the bare command not found is gone.

Another tool missing after a fresh install, or a PATH problem on a different command entirely? See npx: command not found, nvm: command not found, or the general pattern in command not found: the three causes and the fix for every tool.

Frequently asked

How do I install Claude Code?

Anthropic's recommended native installer: curl -fsSL https://claude.ai/install.sh | bash on macOS, Linux or WSL, or irm https://claude.ai/install.ps1 | iex in Windows PowerShell. It installs a standalone binary at ~/.local/bin/claude (or the Windows equivalent) that updates itself automatically.

Why does claude --version still say command not found after installing?

The install directory, ~/.local/bin, is not on your shell's PATH yet. Add it with echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc (or ~/.bashrc for Bash) and run source on that file, or open a new terminal window — the one you installed from keeps its old PATH.

Should I install Claude Code with npm or the native installer?

The native installer is Anthropic's recommended method: it installs a standalone binary that auto-updates in the background. npm (npm install -g @anthropic-ai/claude-code) also works and needs Node.js 22+, but never run it with sudo — that can leave root-owned files under your npm prefix and break later global installs.

How do I remove a conflicting Claude Code install?

which -a claude (or where.exe claude on Windows) lists every claude binary on your PATH. Keep only the native install and remove the rest: npm uninstall -g @anthropic-ai/claude-code for an npm install, or rm -rf ~/.claude/local for a legacy local install from an older version.

Related articles

All troubleshooting