Skip to content

Fix Windows binary resolution for npm global installs#5

Merged
cpaczek merged 1 commit into
cpaczek:mainfrom
jtuskan:fix/windows-npm-binary-resolution
Apr 1, 2026
Merged

Fix Windows binary resolution for npm global installs#5
cpaczek merged 1 commit into
cpaczek:mainfrom
jtuskan:fix/windows-npm-binary-resolution

Conversation

@jtuskan

@jtuskan jtuskan commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Binary resolution: On Windows, where claude returns the extensionless bash shim (npm/claude) not claude.cmd, so the existing .cmd handler never fires. Added fallback to try the .cmd sibling and parse it to find cli.js.
  • Platform candidate typo: Fixed cli.mjs -> cli.js in the Windows fallback path list.
  • Salt thresholds: The Windows JS bundle contains the salt string once (vs 3x in the Linux compiled binary). Lowered all occurrence thresholds from >= 3 to >= 1. Kept the low-count warning for non-Windows platforms where 3 occurrences are expected.

Reproduction

> any-buddy
Error: Salt "friend-2026-401" not found in C:\Users\...\npm\claude.cmd.
Platform: win32, binary: C:\Users\...\npm\claude.cmd

The tool was searching claude.cmd (347-byte shim) instead of cli.js (13MB JS bundle).

Test plan

  • findClaudeBinary() resolves to node_modules/@anthropic-ai/claude-code/cli.js
  • verifySalt() finds 1 occurrence of the salt in cli.js
  • getCurrentSalt() correctly returns patched: false with 1 occurrence
  • runPreflight() passes with ok: true
  • any-buddy current displays the pet correctly
  • Non-Windows platforms still get a warning if salt count < 3

Tested on Windows 11 with Claude Code installed via npm i -g @anthropic-ai/claude-code.

On Windows with npm global install, `where claude` returns the
extensionless bash shim (npm/claude) rather than claude.cmd. The
existing .cmd handler never fires, so findClaudeBinary falls through
to platform candidates which list cli.mjs (should be cli.js) and
claude.cmd (a 347-byte shim, not the binary).

Additionally, the Windows JS bundle (cli.js) contains the salt string
once, but all thresholds required >= 3 occurrences (matching the Linux
compiled binary), causing every salt check to fail.

Fixes:
- Try .cmd sibling when which() returns an extensionless shim
- Fix cli.mjs -> cli.js in Windows platform candidates
- Lower salt occurrence thresholds from >= 3 to >= 1
- Keep salt-count warning for non-Windows platforms (>= 3 expected)

Tested on Windows 11 with Claude Code installed via npm.
@cpaczek

cpaczek commented Apr 1, 2026

Copy link
Copy Markdown
Owner

Reviewing this, will merge son

@cpaczek cpaczek merged commit 5248476 into cpaczek:main Apr 1, 2026
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.

2 participants