Skip to content

fix(runtime): run the native binary of an npm install of Claude Code - #126

Merged
httpsphl merged 1 commit into
mainfrom
fix/claude-from-npm
Oct 2, 2026
Merged

httpsphl merged 1 commit into
mainfrom
fix/claude-from-npm

Conversation

@httpsphl

@httpsphl httpsphl commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Why

A Windows user installed Claude Code with npm, signed in, and could run claude in PowerShell, but Botloft said Claude Code was missing. The daemon found %APPDATA%\npm\claude.cmd, refused it as the npm launcher and stopped searching.

The npm package (seen with 2.1.287) already ships the native binary at node_modules\@anthropic-ai\claude-code\bin\claude.exe; claude.cmd and claude.ps1 only call it. Pointing claude_path at that file fixed it for the user.

What

  • A claude.cmd/.ps1 (on PATH or in claude_path) resolves to the native binary next to it. If that file is still the ~500-byte placeholder the npm postinstall replaces (--omit=optional, --ignore-scripts), the launcher is refused as before.
  • A launcher that cannot run no longer ends the search: later PATH entries are tried, and the launcher error only shows when nothing else works.
  • On Windows, the search also covers %USERPROFILE%\.local\bin (native installer), %LOCALAPPDATA%\Microsoft\WinGet\Links and %APPDATA%\npm, for a PATH set only in a shell profile.
  • The lookup moves to runtime/claude/locate.rs so claude.rs stays short.
  • Spec 7.4 updated; new row in section 19 with what was seen in the npm package.

Tests

  • New unit tests: npm native binary found from the launcher, placeholder refused, search continues past a placeholder launcher to a later claude.exe, Windows usual place found off PATH.
  • cargo fmt --check, clippy -D warnings and cargo test --workspace pass locally.

Manual check (real Claude Code)

  • On a Windows profile with Claude Code installed only via npm i -g @anthropic-ai/claude-code and an empty claude_path, Botloft finds Claude Code and shows the signed-in account.

The npm package (seen with 2.1.287) ships the native claude.exe under
node_modules/@anthropic-ai/claude-code/bin, and its claude.cmd/.ps1 only
call it. The daemon refused the launcher and stopped there, so owners who
installed Claude Code with npm saw it as missing.

- a claude.cmd/.ps1 resolves to that binary, unless it is still the small
  placeholder the npm postinstall replaces
- a launcher that cannot run no longer stops the search; later PATH
  entries are still tried
- on Windows, also look in %USERPROFILE%\.local\bin, WinGet Links and
  %APPDATA%\npm, for a PATH set only in a shell profile

The lookup moves to runtime/claude/locate.rs to keep claude.rs short.
Spec 7.4 and section 19 updated.
@httpsphl
httpsphl merged commit 7440dca into main Oct 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant