Skip to content

fix: resolve claude.cmd shim on Windows before spawning (#120)#121

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/120-windows-claude-cmd-shim
Jun 25, 2026
Merged

fix: resolve claude.cmd shim on Windows before spawning (#120)#121
fdaviddpt merged 1 commit into
mainfrom
fix/120-windows-claude-cmd-shim

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Context

On Windows the npm global install ships the CLI only as a claude.cmd shim (no claude.exe). pipeline/haiku.py spawned it in list-form as subprocess.run(["claude", ...]), which goes through CreateProcess — that resolves only .exe from a bare name. Every spawn raised FileNotFoundError: [WinError 2], the pipeline aborted right after [haiku] calling, and now.md / today-*.md / recent.md were never generated. (The SessionStart hook and /remember skill kept working since they don't spawn claude.) 5th Windows bug, not covered by the four fixed in #6.

Fix

Resolve the binary with shutil.which("claude") before spawning. It honours PATHEXT, returns the full claude.cmd path, and subprocess launches it fine — no shell=True, no argv-length regression, cross-platform safe (returns the plain path on Linux/macOS). Overridable via REMEMBER_CLAUDE_BIN, mirroring the existing REMEMBER_MODEL / REMEMBER_MAX_TURNS knobs. New _resolve_claude_bin() helper, wired into cmd[0].

Tests (TDD)

6 new tests in tests/test_haiku.py: which-resolution (queried for "claude"), .cmd shim path, REMEMBER_CLAUDE_BIN override, blank-override fallback, not-on-PATH fallback to bare name, and cmd[0] is the resolved path. Made the one fragile existing assert path-robust.

Full suite: 487 passed, 41 skipped, 98.5% coverage. Red-before-green confirmed.

Bump

0.8.2 -> 0.8.3 (plugin.json, README.md badge, CHANGELOG.md).

Closes #120

🤖 Generated by Max

On Windows the npm global install ships the CLI only as a `claude.cmd`
shim (no `claude.exe`). `subprocess.run(["claude", ...])` goes through
CreateProcess, which resolves only `.exe` from a bare name, so every
spawn raised `FileNotFoundError: [WinError 2]` — silently killing every
auto-save (now.md / today-*.md / recent.md never generated).

Resolve the binary with `shutil.which("claude")`, which honours PATHEXT
and returns the full claude.cmd path subprocess can launch — no
shell=True, no argv-length regression, cross-platform safe. Overridable
via REMEMBER_CLAUDE_BIN, mirroring the REMEMBER_MODEL / _MAX_TURNS knobs.

Bump 0.8.2 -> 0.8.3.

Co-Authored-By: Max <noreply>
@fdaviddpt fdaviddpt merged commit 9d73249 into main Jun 25, 2026
12 checks passed
@fdaviddpt fdaviddpt deleted the fix/120-windows-claude-cmd-shim branch June 25, 2026 21:07
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.

Windows: subprocess can't launch 'claude' (claude.cmd shim) → WinError 2 kills every auto-save

1 participant