mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
fix(windows): use absolute path with shell:false for Claude spawn (#143)
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>
This commit is contained in:
@@ -347,8 +347,9 @@ export function query(config: {
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
signal: config.options?.abort,
|
||||
env: spawnEnv,
|
||||
// Use shell on Windows for command resolution
|
||||
shell: process.platform === 'win32'
|
||||
// Use shell: false with absolute path from getDefaultClaudeCodePath()
|
||||
// This avoids cmd.exe resolution issues on Windows
|
||||
shell: false
|
||||
}) as ChildProcessWithoutNullStreams
|
||||
|
||||
// Handle stdin
|
||||
|
||||
Reference in New Issue
Block a user