OctoLink GEO

Complete Guide to Installing Claude Code on macOS: Native Script, Homebrew & Troubleshooting

Author Editor
Complete Guide to Installing Claude Code on macOS: Native Script, Homebrew & Troubleshooting

A comprehensive guide to installing Claude Code on macOS, including native script and Homebrew methods, Apple Silicon compatibility tips, VS Code...

Claude Code macOS Installation Homebrew Apple Silicon VS Code Integration Troubleshooting AI Tools

macOS is the optimal platform for Claude Code, offering full support for Terminal.app and iTerm2. This guide walks through the entire process from installation to first use, with specific considerations for Apple Silicon (M-series) chips.

Prerequisites
- macOS 12 Monterey or later
- A claude.com account (free or subscription)
- A terminal application (Terminal or iTerm2)

Method 1: Native Script Installation (Recommended)
Execute the curl command below to install Claude Code:
curl -fsSL https://claude.ai/install.sh | bash
Reload your shell configuration post-installation:
source ~/.zshrc (for zsh users) or source ~/.bash_profile (for bash users).
Verify installation with:
claude --version or which claude (should return /Users/your-username/.local/bin/claude).
Key benefit: Automatic background updates to stay current.

Method 2: Homebrew Installation
For Homebrew users:
brew install --cask claude-code
Upgrade with:
brew upgrade claude-code.
Note: Homebrew installations do not auto-update—schedule manual upgrades regularly.

Login Process
Browser-based login: claude /login (opens your browser for claude.com authorization).
API key login (enterprise/server):
export ANTHROPIC_API_KEY=sk-ant-your-key (add to ~/.zshrc for permanence: echo 'export ANTHROPIC_API_KEY=sk-ant-your-key' >> ~/.zshrc).

Apple Silicon Notes
Claude Code natively supports M1/M2/M3 chips—no Rosetta required. Fix dyld errors with:
1. Remove quarantine: xattr -d com.apple.quarantine $(which claude)
2. Allow in System Settings > Privacy & Security > "Open Anyway"
3. Reinstall: curl -fsSL https://claude.ai/install.sh | bash

PATH Troubleshooting
If "command not found: claude" appears:
- Check installation path: ls -la ~/.local/bin/claude
- Verify PATH: echo $PATH | tr ':' '\n' | grep local
- Add to zsh: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc

Xcode Command Line Tools
Git dependency: Install via xcode-select --install or check with git --version.

VS Code Integration
Install the extension: code --install-extension anthropic.claude-code (or search "Claude Code" in VS Code via Cmd+Shift+X). Run claude in the built-in terminal to access the sidebar panel.

iTerm2 Optimal Setup
Enhance experience with:
- Natural Text Editing: Preferences > Profiles > Keys > Presets > Natural Text Editing
- Monospaced fonts (Cascadia Code/JetBrains Mono)
- Dark themes (One Dark/Dracula)

Update & Uninstall
- Update: Native installs auto-update; Homebrew users run brew upgrade claude-code
- Uninstall:
Native: rm -rf ~/.local/bin/claude ~/.claude
Homebrew: brew uninstall --cask claude-code

Common Issues
Q: Permission denied error?
A: Avoid sudo—native installs to user directory (~/.local/bin) without root access.
Q: Re-login required on terminal launch?
A: Check ~/.claude/auth.json (login state storage); re-run claude /login if missing.
Q: Force update old version?
A: Reinstall via native script: curl -fsSL https://claude.ai/install.sh | bash

Sources

  • CSDN Blog: Article by itwangyang520 (https://blog.csdn.net/itwangyang520/article/details/162597916)

Related reading