Skip to content

fix: route Claude PTY spawn through cmd.exe on Windows - #638

Closed
Jinwoo-H wants to merge 1 commit into
mainfrom
claude-windows-fix
Closed

Jinwoo-H wants to merge 1 commit into
mainfrom
claude-windows-fix

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix Claude usage tracking on Windows — claude-pty.ts spawned 'claude' directly via node-pty, hitting the same .cmd batch script issue fixed for Codex in fix: resolve Codex spawn failures on Windows #562. Now routes through cmd.exe /c on win32.
  • Close a remaining Codex PTY edge case — the fix: resolve Codex spawn failures on Windows #562 fix only routed through cmd.exe when the resolved command had a .cmd/.bat extension, missing the bare 'codex' fallback when resolveCodexCommand() can't locate the binary on disk. Simplified to always use cmd.exe /c on win32.

All changes are guarded by process.platform === 'win32' — zero impact on macOS/Linux.

Test plan

  • Verify Claude usage tracking works on Windows (no "PTY timeout")
  • Verify Codex usage tracking works on Windows when codex is not directly on PATH
  • Verify no regressions on macOS

🤖 Generated with Claude Code

Two gaps from the previous Windows spawn fix:

1. claude-pty.ts spawned 'claude' directly via node-pty, hitting the
   same .cmd batch script issue on Windows. Route through cmd.exe /c
   so Windows handles PATHEXT resolution.

2. codex-fetcher.ts PTY path only routed through cmd.exe when the
   resolved command had a .cmd/.bat extension, missing the bare 'codex'
   fallback case. Simplified to always use cmd.exe /c on win32.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Jinwoo-H Jinwoo-H changed the title fix: route Claude and Codex PTY spawns through cmd.exe on Windows fix: route Claude PTY spawn through cmd.exe on Windows Apr 14, 2026
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Closing in favor of the pnpm-codex-fix branch (Jinwoo-H/pnpm-codex-fix), which subsumes this PR's Windows cmd.exe routing fix for both claude-pty.ts and codex-fetcher.ts, and additionally adds resolveClaudeCommand() path resolution + pnpm/yarn/bun global bin support.

@Jinwoo-H Jinwoo-H closed this Apr 14, 2026
Jinwoo-H added a commit that referenced this pull request Apr 14, 2026
…I-launched apps

GUI-launched Electron apps don't inherit shell PATH, so spawning bare
'codex' or 'claude' fails for users who installed via pnpm, yarn, or bun.

- Generalize resolveCodexCommand() into a shared resolveCommand() that
  works for any CLI name, and export resolveClaudeCommand() alongside it
- Add pnpm global bin dirs (macOS ~/Library/pnpm, Linux ~/.local/share/pnpm,
  Windows AppData/Local/pnpm)
- Add yarn global bin dirs (~/.yarn/bin, Windows AppData/Local/Yarn/bin)
- Add bun global bin (~/.bun/bin on all platforms)
- Wire claude-pty.ts to use resolveClaudeCommand() instead of bare 'claude'
- Simplify Windows PTY spawn to always route through cmd.exe on win32,
  fixing the bare-command PATHEXT fallback edge case (subsumes #638)

Closes #638
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