code: command not found on Mac: install the VS Code Shell Command, and do not confuse it with Claude Code
Frank Zhang
- 5 minutes read - 2115 wordsTL;DR
This error means the current shell has no command named code on PATH. On a Mac, that often means Visual Studio Code is installed, but the official command-line tool has not been added to PATH yet. General guidance, not a first-hand session.
Decide which command you actually want. If you typed code to launch Visual Studio Code, the error means the current shell does not have that CLI on PATH. First check, read-only, whether the VS Code app and the official code binary exist. If the app already opens, use the official Command Palette Shell Command to add code to PATH, then open a new terminal. If you wanted Anthropic’s Claude Code, the command is claude, not code; do not use this page to “fix” that with the VS Code Shell Command. This page is general guidance, not a record of one session. The commands were not re-run on a Mac for this page. There is no first-hand screenshot of the error. The sources are the Visual Studio Code macOS setup page and the Claude Code setup page, as read on 2026-12-04. If which -a code, code --version, the app path on disk, or the text on your screen disagrees, trust that copy.
People usually paste this line:
zsh: command not found: code
In bash it is often bash: code: command not found. Searches are commonly written as code command not found mac.
What this page is for
This page is for code: command not found, zsh: command not found: code, and the common autocomplete forms with mac, macos, terminal, vscode, and zsh, plus install code command in path mac. On 2026-12-04, en-US and zh-CN Google autocomplete for code command not found mac each listed 10 queries, including vscode, zsh, terminal, and claude code command not found mac. The root code command not found also listed 10, including windows, linux, and wsl, which this Mac page does not cover. Autocomplete also surfaced a separate codex query and, on Bing, some unrelated python / node / chmod noise; those are not this page. GSC for www.fzhang.dev (2026-11-05 through 2026-12-03, dataState=all) had no impressions for queries matching code command not found or a VS Code shell command.
This page is not for:
zsh: command not found: brew. See zsh: command not found: brew on Mac: check the prefix, then fix PATH.python: command not found. See python: command not found on Mac: try python3 first, do not patch /usr/bin.- A global CLI that works in your interactive terminal but fails in an AI agent or a non-interactive shell. See command not found after npm install -g: your terminal and the AI agent are using different Node installs.
command not found: claude, or the autocomplete formclaude code command not found mac. That is a different tool, covered only as a boundary below.zsh: command not found: codex. That appeared in autocomplete too; it is notcode, and this page does not cover it.- The same error on Linux, Windows, or WSL. The official PATH instructions differ; do not copy the Mac paths below.
- A Gatekeeper alert when you cannot open the VS Code app itself. See “The developer cannot be verified” on Mac: identify the alert first, do not turn off Gatekeeper.
code and claude are not the same command
Autocomplete lists both code command not found mac and claude code command not found mac. The names are close; the commands are not the same.
Visual Studio Code’s command-line tool is code (or code-insiders for the Insiders preview). Installing Visual Studio Code on macOS, as read on 2026-12-04, says that to start VS Code from a terminal by typing code, you add VS Code to the $PATH environment variable. The documented first choice is the Shell Command in the VS Code Command Palette.
Anthropic’s Claude Code is a different product. Claude Code setup, as read on 2026-12-04, recommends this native install on macOS: curl -fsSL https://claude.ai/install.sh | bash. After it finishes, open a new terminal and run claude --version, not code --version. If the shell says claude is not found, the docs say the install directory is not on PATH yet and point you to Fix your PATH. The same page says the native installer manages the launcher at ~/.local/bin/claude on macOS and Linux.
If the error is command not found: code, follow the VS Code path. If it is command not found: claude, do not run the VS Code Shell Command to “fix” it. This page only draws that line; it does not walk through Claude Code login or account issues.
Read first: is the app there, and is the command there?
In Terminal, start with read-only checks:
command -v code
type -a code
which -a code
ls -l "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
ls -ld "/Applications/Visual Studio Code.app"
code --version
echo "$PATH"
No output from command -v or which, or No such file or directory from ls, is still a useful result. If code --version already prints a VS Code version, Git commit, and architecture, the current shell can find the command. The problem may be another environment (a different terminal window, a script, or an AI agent). Do not reinstall just because a second shell cannot see it.
Treat the output as separate branches.
1. Visual Studio Code.app is not in Applications
The official app is not installed, or it lives somewhere else. Do not invent a code command by editing PATH first. Follow the install steps on Installing Visual Studio Code on macOS: download the macOS build, open the .dmg, drag Visual Studio Code.app into Applications, and open it from there. The download page also lists Universal, Intel, and Apple silicon builds; use the one that matches this Mac.
If double-clicking the app shows “the developer cannot be verified,” go to “The developer cannot be verified” on Mac: identify the alert first, do not turn off Gatekeeper. That alert is not a PATH problem.
If the app is not at /Applications/Visual Studio Code.app, any manual PATH line must use the real Contents/Resources/app/bin inside that copy. This page does not invent paths for other installers.
2. The app is present, but this shell cannot find code
This is the common case: VS Code opens from Applications or the Dock, but Terminal has no code command. The official docs describe this as adding VS Code to $PATH. Use the Shell Command in the next section. Do not reinstall the app first, and do not sudo copy files into system directories.
3. code is found, but it is not VS Code
type -a code may show an alias, a function, or another binary with the same name. The official docs note that if an older VS Code version left a code alias in .bash_profile or an equivalent profile, you should remove that alias and run the Shell Command again. If code --version does not print VS Code version information, do not overwrite that command first; see what it is. This page does not decide whether some other code command should be deleted.
4. You actually wanted claude
If the error is command not found: claude, or you were following Claude Code’s installer, use the official setup page and its Fix your PATH instructions. Do not add the VS Code app/bin path to “repair” claude.
If the app is present: add code to PATH the official way
Installing Visual Studio Code on macOS gives these steps under “Launch VS Code from the command line”:
- Launch VS Code.
- Open the Command Palette (
Cmd+Shift+P), typeshell command, and run Shell Command: Install ‘code’ and optionally ‘copilot’ commands in PATH. - If you are prompted to install GitHub Copilot CLI as well: Yes starts that install in the integrated terminal and continues adding
codeto PATH; No adds onlycode. Escape dismisses the prompt without installing either command. - If you choose Yes, follow the instructions in the terminal, including any shell profile or PATH updates. If Copilot CLI is already installed, that install is reused. The docs also say Copilot CLI installation is separate from adding
codeto PATH: a success message forcodedoes not mean Copilot CLI is finished. - Restart the terminal so the new
$PATHtakes effect.
You can then run code . in any folder to edit that folder. If you installed Copilot CLI, the terminal command is copilot, not code. This page only aims to make code available; Copilot CLI is optional.
The same page notes two UI differences:
- In Insiders, the command is
code-insiders, notcode. - If AI features are hidden, or your organization disables Copilot CLI installation, the Command Palette keeps the older label Shell Command: Install ‘code’ command in PATH and does not offer Copilot CLI.
Trust the command you actually see. After installing, open a new terminal and rerun the read-only checks. For Insiders, look for code-insiders.
If the Shell Command is missing from the palette, confirm you opened Visual Studio Code (or Insiders), not a different editor, then use the official manual PATH snippet.
If you need it: add PATH manually, as the docs show
The same page also shows a manual PATH setup. Confirm ls can see bin/code first. For Zsh, the default shell on recent macOS, the documented example appends this block to ~/.zprofile:
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
For Bash, the same PATH line is appended to ~/.bash_profile. The docs note that the leading backslash in \$PATH prevents $PATH from expanding during concatenation; remove the backslash when you run the export command directly in a terminal.
Open a new terminal, then run code . or command -v code. Do not paste the same block into many profile files “just in case,” and do not start by editing a system-wide path file.
If VS Code is not at /Applications/Visual Studio Code.app, change the path to the real .../Visual Studio Code.app/Contents/Resources/app/bin. Trust ls.
Related, but not the same problem
- A missing
brewcommand is a different prefix andshellenvstep. See zsh: command not found: brew on Mac: check the prefix, then fix PATH. - A missing
pythoncommand is python: command not found on Mac: try python3 first, do not patch /usr/bin. - A global npm CLI that works in an interactive terminal but fails in an AI agent is command not found after npm install -g: your terminal and the AI agent are using different Node installs.
- If the app itself will not open because the developer cannot be verified, see “The developer cannot be verified” on Mac: identify the alert first, do not turn off Gatekeeper.
Do not start here
- Do not
sudocopy a binary into/usr/bin, and do not modify or delete system directories to create acodecommand. - Do not uninstall and reinstall VS Code just to fix
command not foundif the app already opens. The usual gap is PATH. - Do not download a random script named
code, and do not run an undocumented installer from an untrusted page. - Do not treat the Claude Code install script as a fix for VS Code’s
code, and do not treat the VS Code Shell Command as an install step forclaude. - Do not turn off Gatekeeper or System Integrity Protection to make the word
codeappear.
Where this page stops
- The commands were not re-run for this page. There is no first-hand screenshot. The sources are the official Visual Studio Code and Claude Code pages cited above, as read on 2026-12-04.
- This page does not compare other editors’ CLIs, and it does not verify app names that may appear in autocomplete.
- It does not give steps for turning off Gatekeeper or SIP, or for copying files into system directories.
- Command Palette wording can differ between stable, Insiders, and organization policy; trust the label you see and the current official docs.
- This page does not include a separate keyword-volume study. Autocomplete only shows that people search these phrases.
For the rest of the reading path, see Start here. The Chinese page is a separate write-up of the same topic: code: command not found:Mac 上先装 VS Code 的命令行工具,不要当成 Claude Code.
If this post helps, you can sponsor the blog. This is voluntary personal support, not a charitable donation.