fix(windows): resolve CLI detection and process spawning on Windows#1092
Open
MabuhayDesignsandCo wants to merge 3 commits intoruvnet:mainfrom
Open
fix(windows): resolve CLI detection and process spawning on Windows#1092MabuhayDesignsandCo wants to merge 3 commits intoruvnet:mainfrom
MabuhayDesignsandCo wants to merge 3 commits intoruvnet:mainfrom
Conversation
On Windows, `which` is not available — use `where` instead for CLI detection. Additionally, spawn/spawnSync/execSync calls need `shell: true` (or `shell: process.platform === 'win32'`) to resolve executables from PATH on Windows. Fixes: - hive-mind.ts: Use `where` on win32 for claude CLI detection - hive-mind.ts: Enable shell for claude process spawn on Windows - auto-install.ts: Enable shell for npm spawn on Windows - headless-worker-executor.ts: Enable shell for claude version check and claude process spawn on Windows - doctor.ts: Enable shell for npm install on Windows Closes ruvnet#615 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of using shell: true (which routes through cmd.exe and introduces command injection risks and process orphaning), resolve the claude command to its absolute filesystem path on Windows. Adds resolve-command.ts utility: - resolveCommand(): scans PATH for .cmd/.bat/.exe on Windows - isCommandAvailable(): cross-platform command existence check This eliminates: - Command injection via cmd.exe metacharacter escaping weaknesses - Process orphaning where kill() targets cmd.exe instead of claude - No-op shell options on execSync calls (which always use a shell) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused `join` import from path module
- Replace dynamic `require('child_process')` with top-level ESM import
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes Windows compatibility issues where claude-flow fails to detect Claude Code CLI and fails to spawn processes correctly on Windows.
Root cause: On Windows, the
whichcommand doesn't exist (it'swhere), andspawn/spawnSync/execSynccalls needshell: trueto resolve executables from PATH.Changes
hive-mind.tswhereinstead ofwhichon win32 for Claude CLI detectionhive-mind.tsshell: process.platform === 'win32'for claude process spawnauto-install.tsheadless-worker-executor.tsclaude --versioncheck and claude spawndoctor.tsnpm installininstallClaudeCode()Additional Windows issues found (not in this PR)
During investigation, 47+ additional instances of missing Windows compatibility were identified across the codebase:
statusline-generator.ts: Unix-style2>/dev/nullredirections, missingshelloptionsinit.ts: Unix-style&background operator,2>/dev/nullredirectionssecurity.ts: Missing shell options fornpm auditcommandsbrowser-tools.ts: Missing shell foragent-browserspawngcs.ts: Hardcoded/tmppaths (should useos.tmpdir())container-worker-pool.ts: Missing shell for docker spawnRecommendation: Consider adding a shared
shellOption()helper:Testing
Tested on:
All three core scenarios now work:
claude-flow doctorcorrectly detects Claude Code CLIclaude-flow swarmsuccessfully spawns Claude instancesclaude-flow mcp startauto-installs packages via npmCloses #615