Agent fails to spawn claude on Windows when the CLI is installed via npm (.ps1/.cmd shim) #63
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
kahliburke/Kaimon.jl#63
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On Windows, an npm-installed Claude Code CLI provides
claude.ps1/claude.cmdshims on PATH rather than an.exe. Kaimon's agent service spawns`claude -p ...`directly, and libuv/Base.runonly resolves real executables — so opening the agent fails with:...even though
claude --versionworks fine in the user's shell.Installing the native build (
irm https://claude.ai/install.ps1 | iex, which dropsclaude.exeinto~/.local/bin) fixes it.Suggestions (any subset):
Sys.which("claude") === nothingwhile aclaude.cmd/claude.ps1exists on PATH, raise a clear error telling the user to install the native CLI.cmd /c claude ...on Windows when only a shim is present.Also worth noting: the ENOENT error message currently dumps the entire environment block (including any API keys in the user's environment) into the UI — trimming that would avoid accidental secret leaks when users paste errors into issues.
Ah Windows ... ;) will try to take a look in a few days.
Fixed by #66 (merged to
main; ships in the next release — it landed just after the 2.0.8 bump, so it'll be in 2.0.9, not 2.0.8).Root cause (thanks for the sharp report — and for pinpointing the shim angle): on Windows,
Sys.whichresolves a bare command name only as.exe— it ignoresPATHEXTentirely. So an npm-installedclaude(a.cmd+.ps1shim, no.exe) is invisible toSys.which, and thus toBase.run/libuv, which ENOENTs — even thoughclaude --versionworks in your shell. Confirmed on a fresh Windows instance:Sys.which("claude")returnsnothingwhileSys.which("claude.cmd")resolves fine.Two fixes:
Shim resolution —
launch_argvnow falls back to aPATH×PATHEXTsearch whenSys.whichcomes up empty, finds the.cmd/.ps1, and wraps it through its interpreter (cmd.exe /d /c/powershell -File) as before. So the npm CLI works directly — the native installer is no longer required. Covers every CLI spawn (claude/gemini/codexMCP commands and the agent). Verified end-to-end on real Windows: bareclaude→ resolved to the.cmd→ wrapped → spawns with args passed through.The secret leak (the important note at the bottom of your report) — a failed spawn's
IOErrorstringified the wholesetenv(cmd, env), including the process environment, surfaced verbatim in the UI. Fixed: spawn failures now re-raise a sanitized error built from the argv alone (no env), with an actionable hint. No more dumpingANTHROPIC_API_KEYinto a pasteable error.