claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] The CLI reports that the Claude command is not found but still works

Open kud opened this issue 1 year ago β€’ 17 comments

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other:
  • Claude CLI version: 1.0.68 (Claude Code)
  • Operating System: macOS 15.5
  • Terminal: iTerm2

Bug Description

The CLI reports that the Claude command is not found at /Users/xxx/.local/bin/claude, and indicates that ~/.local/bin is not in the PATH, despite the command working from /opt/homebrew/bin/claude.

Steps to Reproduce

  1. Try running the claude command from the terminal.
  2. Observe the error message stating the command is not found in the specified directory.
  3. However, using which claude shows it working from /opt/homebrew/bin/claude.

Expected Behavior

The claude command should execute without error, given that it works from /opt/homebrew/bin and is symlinked correctly.

Actual Behavior

An error message appears stating that the command is not found at /Users/xxx/.local/bin/claude and suggests adding ~/.local/bin to the PATH, though it isn't the correct directory for this command.

Additional Context

  • Error message details:
  • Claude command not found at /Users/mest001/.local/bin/claude
  • ~/.local/bin is not in your PATH
  • Suggests adding it to the PATH using export PATH="~/.local/bin:$PATH"
  • The which claude command confirms it works from /opt/homebrew/bin/claude.
  • The symlink details:
/opt/homebrew/bin/claude β‡’ ../lib/node_modules/@anthropic-ai/claude-code/cli.js
  • Additional terminal output suggests network issues with connection errors and retries.
  • It was installed via npm.

kud avatar Aug 05 '25 14:08 kud

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/2824
  2. https://github.com/anthropics/claude-code/issues/4453
  3. https://github.com/anthropics/claude-code/issues/3172

If your issue is a duplicate, please close it and πŸ‘ the existing issue instead.

πŸ€– Generated with Claude Code

github-actions[bot] avatar Aug 05 '25 14:08 github-actions[bot]

Hey there.

Is there any reason why we need Claude in .local/bin?

I've set my npm prefix that way, Claude works well but I still have the message.

πŸ” Command: claude
────────────────────
claude is /Users/xxx/.npm-global/bin/claude

ℹ️  Additional Information:
Version: 1.0.81 (Claude Code)
File type: a /usr/bin/env node script text executable, ASCII text, with very long lines (29314)
Size: 52B

kud avatar Aug 15 '25 17:08 kud

Also reporting the same; using claude with NPM installed globally, i.e.

βœ— which claude
/Users/xxxx/.nvm/versions/node/v24.6.0/bin/claude

however Claude still works fine.

josh-at-block avatar Aug 26 '25 19:08 josh-at-block

Possible solution: show npm error in claude? I had the same issue that was caused by a wrong .npmrc config

khalic-lab avatar Aug 27 '25 06:08 khalic-lab

Same problem. Running in WSL2. Nothing in my PATH referencing any claude folders. Seems to be working fine otherwise.

 ● Claude command not found at /home/jpreed/.local/bin/claude

jpreed@XPS-8960:~$ which claude
/home/jpreed/.nvm/versions/node/v22.18.0/bin/claude

jpreed2 avatar Aug 28 '25 16:08 jpreed2

@jim5359

If you are seeing ● Claude command not found at /Users/[your_user]/.local/bin/claude, then:

  • Run claude config get --global installMethod outside claude code
  • Run /doctor inside claude.

If your installMethod shows as "native" and claude doctor command shows Config install method: npm, then:

  • Run claude config set --global installMethod npm

My guess is that this happens when you tried switching from npm installation to native without noticing some claude session was still running which messes up the configuration.

mrns avatar Aug 30 '25 14:08 mrns

@mrns This did the trick!

@jim5359

If you are seeing ● Claude command not found at /Users/[your_user]/.local/bin/claude, then:

  • Run claude config get --global installMethod outside claude code
  • Run /doctor inside claude.

If your installMethod shows as "native" and claude doctor command shows Config install method: npm, then:

  • Run claude config set --global installMethod npm

My guess is that this happens when you tried switching from npm installation to native without noticing some claude session was still running which messes up the configuration.

ryanspooner avatar Aug 30 '25 15:08 ryanspooner

@mrns Thanks for the tip. For me, ironically, it turns out turning off WSL support solved the problem, even though I'm using WSL. The WSL support allows specifying the exact location of the binaries, but apparently it didn't work in my setup and turning it off did.

jpreed2 avatar Aug 30 '25 15:08 jpreed2

@jim5359 's suggestion did not resolve this for me. I'm using Homebrew to install claude and I have installMethod set to homebrew. I still get:

● Native installation exists but ~/.local/bin is not in your PATH. Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.config/zsh/.zshrc && source ~/.config/zsh/.zshrc

When I launch Claude and running /doctor within claude shows:

Diagnostics
 β”” Currently running: native (1.0.117)
 β”” Path: /opt/homebrew/bin/claude
 β”” Invoked: /opt/homebrew/Caskroom/claude-code/1.0.117/claude
 β”” Config install method: homebrew
 β”” Auto-updates enabled: false
 β”” Search: OK (bundled)
 Warning: Native installation exists but ~/.local/bin is not in your
  PATH
 Fix: Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >>
 ~/.config/zsh/.zshrc then open a new terminal or run: source
 ~/.config/zsh/.zshrc
 Warning: Running native installation but config install method is 
 'homebrew'
 Fix: Run claude install to update configuration

 Press Enter to continue…

Running claude install of course installs claude in ~/.local/bin but that is not what I want. Any other suggestions on how to get rid of the false error?

xjones avatar Sep 22 '25 15:09 xjones

I had initially used the native installer and switched to npm, I resolved this by updating "installMethod": "native", to "installMethod": "npm", in ~/.claude.json

ernestns avatar Sep 30 '25 03:09 ernestns

Can you please provide a working brew installation? This is getting ridiculous. Why would I use npm to install it? npm sucks big time

alamothe avatar Oct 01 '25 19:10 alamothe

Yeah, I am getting the same issue, there is no config option anymore, install via brew on Mac:

[I] ❰dan❙~/a(git:main)β±βœ”β‰» claude doctor

 Diagnostics
 β”” Currently running: native (2.0.8)
 β”” Path: /opt/homebrew/bin/claude
 β”” Invoked: /opt/homebrew/Caskroom/claude-code/2.0.8/claude
 β”” Config install method: unknown
 β”” Auto-updates enabled: default (true)
 β”” Search: OK (bundled)
 Warning: Running native installation but config install method is 'unknown'
 Fix: Run claude install to update configuration
 Warning: Leftover npm global installation at /opt/homebrew/bin/claude
 Fix: Run: npm -g uninstall @anthropic-ai/claude-code

 Press Enter to continue…

hnykda avatar Oct 06 '25 11:10 hnykda

What does "native" even mean in this context? Claude code stopped working for me randomly, I suspect because of some auto-update mechnism, and I'm trying to diagnose it. I don't see anything other than an npm installation instruction in the readme. My install says my "installMethod is native" but can't find the binary, and /doctor says I have multiple installations but doesn't tell me what to do about that.

Edit for anyone else that might be running into this. The readme doesn't link to this advanced instructions page, which has other setup methods. I have no clue how mine got screwed up though. Just suddenly stopped working.

dellis23 avatar Oct 07 '25 19:10 dellis23

Upgrading the claude-code formula in brew fixed this for me.

dragonfax avatar Nov 10 '25 05:11 dragonfax

Yeah I don't have the issue anymore too.

kud avatar Nov 10 '25 11:11 kud

Upgrading the claude-code formula in brew fixed this for me.

This work for me too, thanks

mangubee avatar Nov 12 '25 13:11 mangubee

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Nov 19 '25 14:11 github-actions[bot]