fix(windows): use absolute path with shell:false for Claude spawn#143
Merged
tiann merged 1 commit intotiann:mainfrom Feb 3, 2026
Merged
fix(windows): use absolute path with shell:false for Claude spawn#143tiann merged 1 commit intotiann:mainfrom
tiann merged 1 commit intotiann:mainfrom
Conversation
On Windows, spawning Claude with shell: true causes the process to exit immediately with code 1. This happens because shell: true invokes cmd.exe /c claude <args>, and cmd.exe's PATH resolution differs from direct process creation, leading to environment inconsistencies. This fix: - Adds findWindowsClaudePath() to locate claude.exe absolute path - Changes spawn to use absolute path with shell: false on Windows - Maintains Unix behavior (command name works fine with shell: false) - Adds HAPI_CLAUDE_PATH env var for user override Tested on Windows 11 with Claude Code v2.1.29 and hapi v0.15.0. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
| logger.debug(`[ClaudeLocal] Spawning claude with args: ${JSON.stringify(args)}`); | ||
|
|
||
| // Get Claude executable path (absolute path on Windows for shell: false) | ||
| const claudeCommand = getDefaultClaudeCodePath(); |
There was a problem hiding this comment.
[MINOR] [CLEANUP] MCP config cleanup can be skipped on early failure
Why this is a problem: getDefaultClaudeCodePath() can throw before the try/finally, so cleanupMcpConfig never runs. On Windows this can leave a mcp-config-*.json file with server config in the project dir.
Suggested fix:
try {
const claudeCommand = getDefaultClaudeCodePath()
logger.debug(`[ClaudeLocal] Using claude executable: ${claudeCommand}`)
await spawnWithAbort({ command: claudeCommand, args, /* existing options */ })
} finally {
cleanupMcpConfig?.()
process.stdin.resume()
restoreTerminalState()
}There was a problem hiding this comment.
Findings
- [Minor] MCP config cleanup can be skipped if Claude path resolution fails before the try/finally in
cli/src/claude/claudeLocal.ts:89. Suggested fix: movegetDefaultClaudeCodePath()into the try block so cleanup always runs.
Testing
- Not run (automation)
This was referenced Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, spawning Claude with shell: true causes the process to exit immediately with code 1. This happens because shell: true invokes cmd.exe /c claude , and cmd.exe's PATH resolution differs from direct process creation, leading to environment inconsistencies.
This fix:
Tested on Windows 11 with Claude Code v2.1.29 and hapi v0.15.0.