Skip to main content
Claudebeginner

Fix "zsh: permission denied: claude" — Claude Permission Denied Errors

Fix `zsh: permission denied: claude` in one command. Covers the same claude permission denied error in bash, sh and fish, plus npm EACCES and Homebrew permission failures.

9 min readUpdated August 2026

Want us to handle this for you?

Get expert help →

If your terminal prints zsh: permission denied: claude, the fix is one command:

chmod +x "$(command -v claude)"

That error does not mean Claude Code failed to install. It means the opposite: your shell found the claude file and was refused permission to execute it, almost always because the executable bit is missing. Run the command above, then run claude --version to confirm.

If command -v claude prints nothing, or chmod itself fails with another permission error, work through the rest of this guide. It covers the same claude permission denied error in every shell, plus the npm EACCES and Homebrew permission failures that produce it during installation.

Fix "permission denied: claude" in Any Shell

The wording changes between shells, but the cause and the fix do not.

ShellWhat you see
zsh (macOS default)zsh: permission denied: claude
bashbash: /home/you/.local/bin/claude: Permission denied
sh / dashsh: /home/you/.local/bin/claude: Permission denied
fishfish: Unknown command. '/home/you/.local/bin/claude' exists but is not an executable file.

zsh names the command you typed; bash, sh and fish name the full path to the file. fish is the most explicit about what is actually wrong, and it applies to all four.

Step 1: Find the file

command -v claude
ls -la "$(command -v claude)"

Read the permission column on the left of the ls output:

-rw-r--r--  1 you  staff  1234567 Aug  1 09:12 /Users/you/.local/bin/claude   # broken: no x
-rwxr-xr-x  1 you  staff  1234567 Aug  1 09:12 /Users/you/.local/bin/claude   # correct

An x must appear in the owner's permission block. If it does not, the file cannot be executed no matter which shell you use.

Step 2: Restore the executable bit

chmod +x ~/.local/bin/claude

Use the path that command -v claude actually printed — Homebrew installs land under /opt/homebrew/bin on Apple Silicon or /usr/local/bin on Intel Macs, and npm installs land under your npm prefix.

Step 3: If chmod is also denied

chmod: changing permissions of '...': Operation not permitted means you do not own the file. This is the classic aftermath of installing with sudo. Take ownership back:

sudo chown "$(whoami)" ~/.local/bin/claude
chmod +x ~/.local/bin/claude

If the directory is root-owned as well, fix it too:

sudo chown -R "$(whoami)" ~/.local/bin

Why this sometimes shows up as "command not found" instead

When your shell searches PATH, it skips entries that are not executable and keeps looking. So a claude file with broken permissions in one PATH directory produces permission denied only when no other match exists further along your PATH — otherwise you get command not found: claude, or worse, a stale second copy runs instead. If the two errors seem to alternate, list every copy on your system:

# zsh and bash
type -a claude

# All PATH directories, one per line, to spot duplicates
echo "$PATH" | tr ':' '\n'

Delete the copies you do not want, and keep one.

Using claude doctor for Diagnostics

Before troubleshooting manually, run the built-in diagnostic tool:

claude doctor

This command checks:

  • Installation type (native vs npm)
  • PATH configuration
  • Authentication status
  • System permissions
  • File access capabilities

The output highlights specific issues and often suggests fixes. Always start here when debugging problems.

Installation Permission Errors

EACCES Permission Denied (npm installations)

A global npm install fails with a message shaped like this:

npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules/@anthropic-ai
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@anthropic-ai'

The npm error path line is the important one: it names the directory your user cannot write to. Confirm where npm is trying to install and who owns it:

npm root -g
ls -ld "$(npm root -g)"

If that directory is owned by root, do not use sudo and do not chown system directories such as /usr/local/lib. Both approaches leave root-owned files in your Node installation that break the next update. Use one of these solutions instead:

Solution 1: Use the Native Installer (Recommended)

The native installer avoids npm permission issues entirely:

# macOS/Linux
curl -fsSL https://claude.ai/install.sh | bash

# Windows (PowerShell)
irm https://claude.ai/install.ps1 | iex

Solution 2: Fix npm Global Directory Permissions

If you must use npm, configure it to use a user-owned directory:

# Create a directory for global packages
mkdir -p ~/.npm-global

# Configure npm to use it
npm config set prefix '~/.npm-global'

# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
export PATH=~/.npm-global/bin:$PATH

# Reload your shell
source ~/.bashrc  # or source ~/.zshrc

# Now install Claude Code
npm install -g @anthropic-ai/claude-code

Solution 3: Use nvm (Node Version Manager)

nvm manages Node.js in your home directory, avoiding permission issues:

# Install nvm (see nvm docs for latest)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Install and use a Node version
nvm install --lts
nvm use --lts

# Install Claude Code (no sudo needed)
npm install -g @anthropic-ai/claude-code

Switching Node versions this way fixes the permission problem but can surface an unrelated one in your other projects. Node 17 moved to OpenSSL 3, so an older webpack build that worked on Node 16 may now stop with digital envelope routines::unsupported — that is the new Node version, not the nvm switch itself, and nvm use 16 will confirm it either way.

Homebrew Permission Errors

If you install Node, or Claude Code itself, through Homebrew, permission failures surface as Ruby file-system errors naming Homebrew's own prefix:

Error: Permission denied @ dir_s_mkdir - /opt/homebrew/Cellar
Error: Permission denied @ rb_sysopen - /opt/homebrew/var/homebrew/locks/...

Homebrew expects to own its prefix and to run as your normal user. Diagnose first, then take ownership of the prefix rather than running brew under sudo:

# Always start here — brew doctor names most permission problems directly
brew doctor

# Confirm your prefix: /opt/homebrew on Apple Silicon, /usr/local on Intel Macs
brew --prefix

# Give your user ownership of the prefix contents
sudo chown -R "$(whoami)" "$(brew --prefix)"/*

Two follow-on notes. First, if you have ever run sudo brew install, expect several root-owned directories; the chown -R above is what clears them. Second, if claude was installed by Homebrew, its binary lives under $(brew --prefix)/bin, so that is the path to chmod +x — not ~/.local/bin.

PATH Issues

"command not found: claude"

This is a discovery failure rather than a permission failure — the shell never found the file. It has its own walkthrough at zsh: command not found: claude.

After installation, if your terminal cannot find the claude command:

Step 1: Close and Reopen Terminal

The installer modifies your PATH, but changes only apply to new terminal sessions.

Step 2: Verify Installation Location

Check where Claude was installed:

# macOS/Linux native install
ls -la ~/.local/bin/claude

# Check if in PATH
echo $PATH | tr ':' '\n' | grep -E "(local|npm)"

Step 3: Manually Add to PATH

If the binary exists but is not in PATH, add it manually:

# For native installer on macOS/Linux
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# For Homebrew on macOS
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Windows PATH Issues

On Windows, the native installer adds Claude to your user PATH automatically. If the command is still not found:

  1. Restart your terminal (PowerShell or CMD)
  2. Check user PATH:
    • Open Settings > System > About > Advanced system settings
    • Click "Environment Variables"
    • Verify the Claude installation path is in your user PATH
  3. Try a new terminal window rather than an existing one

Authentication Failures

OAuth Browser Issues

Claude Code authenticates via browser. If authentication fails:

Clear Cached Credentials

claude auth logout
claude auth login

# Check the result at any time
claude auth status

If the failure is specifically OAuth token has expired, nothing is wrong with your install or your permissions — the stored session has simply lapsed, and /login inside a session restores it without a full logout.

Check Browser Availability

Ensure your default browser can open. On headless systems or WSL, you may need to configure a browser:

# WSL: Open browser on Windows host
export BROWSER="explorer.exe"

Verify Subscription Status

Visit claude.ai and confirm your Pro or Max subscription is active. API-only accounts need billing enabled with sufficient credits.

Proxy and Network Issues

If you are behind a corporate proxy:

# Set proxy environment variables
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"

# Then authenticate
claude auth login

Sandbox Permission Problems

Claude Code uses sandboxing to safely execute commands. Sandbox issues are platform-specific.

macOS Sandbox Permissions

If Claude cannot access certain directories:

  1. Grant Full Disk Access: System Settings > Privacy & Security > Full Disk Access > Add your terminal app
  2. Check folder permissions: Ensure your user owns the project directory

Windows Sandboxing (WSL)

Native Windows does not support sandboxing. For sandboxed execution, use WSL 2:

# Inside WSL 2
curl -fsSL https://claude.ai/install.sh | bash

Note: WSL 1 does not support sandboxing. Only WSL 2 provides this capability.

Linux Sandbox Issues

On Linux, sandboxing requires certain capabilities. If sandbox operations fail:

# Check if you're in a container or restricted environment
cat /proc/1/cgroup

# Some container environments may not support sandboxing
# In these cases, consider running without sandbox (less secure)

File System Permission Issues

When Claude cannot read or write files in your project:

Check Directory Ownership

# View ownership
ls -la /path/to/project

# Fix ownership (replace 'youruser' with your username)
sudo chown -R youruser:youruser /path/to/project

Verify File Permissions

# Make files readable/writable
chmod -R u+rw /path/to/project

# For directories, ensure execute permission for traversal
find /path/to/project -type d -exec chmod u+x {} \;

Configuring Default Permissions

To reduce permission prompts, configure defaults in your settings:

Claude Code reads settings.json from ~/.claude/ for your user and from .claude/ inside a project. Add standing allow rules there so routine operations stop prompting:

# User-level settings
ls -la ~/.claude/settings.json

# Project-level settings (checked into the repo, or local overrides)
ls -la .claude/settings.json .claude/settings.local.json

You can also use the --dangerously-skip-permissions flag for one-off operations, though this is not recommended for regular use as it bypasses security checks.

Platform-Specific Troubleshooting

macOS

  • Gatekeeper blocks execution: Right-click the installer and select "Open" to bypass Gatekeeper, or run xattr -d com.apple.quarantine /path/to/installer
  • Homebrew issues: Run brew doctor to diagnose Homebrew problems before installing Claude Code via Homebrew

Windows (Native)

  • PowerShell execution policy: If scripts are blocked, run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned in PowerShell as Administrator. On a managed machine that command often fails or is silently overridden — running scripts is disabled on this system explains which scope wins and how to unblock a single script instead
  • Antivirus interference: Temporarily disable real-time scanning if installation repeatedly fails
  • Long path issues: Enable long paths via Group Policy or registry if you work with deeply nested directories

Windows (WSL)

  • WSL version: Run wsl -l -v to verify you are using WSL 2 (required for sandboxing)
  • Mounting Windows drives: Files on /mnt/c/ may have permission issues. Work within the Linux filesystem (~/) when possible

Linux

  • SELinux/AppArmor: Security modules may block Claude operations. Check dmesg or /var/log/audit/audit.log for denials
  • Snap/Flatpak terminals: Sandboxed terminal apps may have limited access. Use a native terminal instead

Still Having Issues?

If you have tried the above solutions without success:

  1. Run diagnostics: claude doctor provides detailed system information
  2. Check GitHub Issues: Search the Claude Code repository for similar problems
  3. Collect logs: Error messages and claude doctor output help when seeking support
  4. Try reinstalling: A fresh installation often resolves corrupted state
# Reinstall the native build in place
claude install stable --force

# Or remove the binary and run the installer again
rm -f ~/.local/bin/claude
curl -fsSL https://claude.ai/install.sh | bash

Removing the binary leaves your configuration in ~/.claude/ intact. Delete that directory only if you want to reset settings, credentials and history as well.

Next Steps

Shipping code with AI?

Get alerted when it breaks

AI assistants ship code you didn't write line-by-line. GlitchReplay gives you error tracking plus session replay — so when AI-generated code breaks in production, you see the exact stack trace and the user's screen. Sentry-SDK compatible, flat-rate pricing.

Try GlitchReplay free

Frequently Asked Questions

Find answers to common questions

The claude file exists and your shell found it, but the file is not marked executable. Run 'chmod +x ~/.local/bin/claude' and try again. This usually happens after an interrupted install, after copying the binary between machines, or after extracting it from an archive that dropped the permission bits.

Run 'ls -la $(command -v claude)' to find the file, then 'chmod +x' that path. If the file is owned by root because you installed with sudo, also run 'sudo chown $(whoami) ~/.local/bin/claude'. If chmod itself fails, you do not own the file or the directory.

Both mean the same thing. zsh prints 'zsh: permission denied: claude' using the command name, bash prints 'bash: /home/you/.local/bin/claude: Permission denied' using the full path, and fish prints 'Unknown command. ... exists but is not an executable file'. The fix is identical in all three shells.

npm is trying to write to a global directory your user does not own, usually /usr/local/lib/node_modules. Do not fix it with sudo. Use the native installer instead, or point npm at a user-owned prefix with 'npm config set prefix ~/.npm-global' and add ~/.npm-global/bin to your PATH.

No. sudo installs files owned by root into directories your user cannot write, which converts a one-time permission error into a permanent one and breaks later updates. Every fix on this page runs as your normal user.

Homebrew cannot write to its own prefix. Run 'brew doctor' first, then take ownership of the prefix with 'sudo chown -R $(whoami) $(brew --prefix)/*'. On Apple Silicon the prefix is /opt/homebrew; on Intel Macs it is /usr/local.

The installation path is not in your PATH. Open a new terminal first, since PATH changes only apply to new sessions. If it still fails, check 'ls -la ~/.local/bin/claude' and add that directory to your shell profile. Note that a file that exists but is not executable is skipped during PATH search, so a broken permission bit can show up as 'command not found' rather than 'permission denied'.

Claude Code asks before file operations and command execution. Configure standing allow rules in your settings.json, or use --dangerously-skip-permissions for a sandboxed one-off run. The flag bypasses security checks, so it is not appropriate for normal work.

Run 'claude auth logout' then 'claude auth login'. Check status at any time with 'claude auth status'. Ensure a browser can open for the OAuth flow, and confirm your Claude subscription is active at claude.ai.