Skip to content

fix: run shell tools via PowerShell on Windows (closes #11)#12

Merged
PentesterFlow merged 2 commits into
mainfrom
fix/windows-shell-spawn
Jun 11, 2026
Merged

fix: run shell tools via PowerShell on Windows (closes #11)#12
PentesterFlow merged 2 commits into
mainfrom
fix/windows-shell-spawn

Conversation

@PentesterFlow

Copy link
Copy Markdown
Owner

Problem

On Windows, every command failed with:

error: ENOENT: no such file or directory, uv_spawn '/bin/sh'

ShellTool and BashTool hardcoded /bin/sh / /bin/bash and spawned them directly (src/tools/shell.ts). Those paths don't exist on Windows, so the spawn ENOENT'd regardless of whether the user ran from CMD or PowerShell. Fixes #11.

Fix

When process.platform === 'win32':

  • Spawn via PowerShellpowershell.exe -NoProfile -NonInteractive -Command <cmd>, overridable with PFLOW_WINDOWS_SHELL (e.g. pwsh.exe).
  • Skip the Unix portability layer — the grep -P → perl rewrite and the GNU-only-flag guards target macOS/BSD/Linux tooling; under PowerShell they would corrupt commands or throw misleading "use macOS/BSD" errors.
  • Process teardown — POSIX negative-PID process groups and signals don't exist on Windows, so we leave the child attached and tear the tree down with taskkill /pid <pid> /T /F.
  • Accurate guidance — tool descriptions and the command schema reflect PowerShell on Windows.

POSIX behavior is unchanged (Windows code paths are all guarded by IS_WINDOWS).

Not covered

The reporter also noted local models "seem to have issues with WSL." That's a separate networking matter (agent in WSL reaching a model server on the Windows host) unrelated to the /bin/sh spawn bug, so it's out of scope here.

Verification

  • npm run typecheck
  • npm run lint
  • npx vitest run — 596/596 pass ✅

🤖 Generated with Claude Code

SecFathy and others added 2 commits June 11, 2026 09:07
The shell and bash tools hardcoded /bin/sh and /bin/bash, which don't
exist on Windows, so every command failed with
`ENOENT: no such file or directory, uv_spawn '/bin/sh'` (issue #11).

On Windows now:
- Spawn commands through PowerShell (-NoProfile -NonInteractive -Command),
  overridable via PFLOW_WINDOWS_SHELL.
- Skip the macOS/BSD portability rewrite and GNU-flag guards (they target
  Unix tools and would corrupt or wrongly block PowerShell commands).
- Tear down the child tree with `taskkill /T /F` and leave the process
  attached, since POSIX process groups/signals don't apply.
- Surface PowerShell-appropriate tool descriptions/schema.

POSIX behavior is unchanged. All 596 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Make the platform check call-time (isWindows()) and export shellInvocation
so the Windows code paths are testable from a POSIX CI host. Adds tests
that the shell/bash tools target PowerShell (not /bin/sh) on win32, honor
PFLOW_WINDOWS_SHELL, skip the Unix grep -P rewrite, and surface PowerShell
guidance — guarding against a regression of issue #11.

602 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PentesterFlow PentesterFlow merged commit 75dc79a into main Jun 11, 2026
4 checks passed
@PentesterFlow PentesterFlow deleted the fix/windows-shell-spawn branch June 11, 2026 06:29
PentesterFlow added a commit that referenced this pull request Jun 12, 2026
* fix: run shell tools via PowerShell on Windows instead of /bin/sh

The shell and bash tools hardcoded /bin/sh and /bin/bash, which don't
exist on Windows, so every command failed with
`ENOENT: no such file or directory, uv_spawn '/bin/sh'` (issue #11).

On Windows now:
- Spawn commands through PowerShell (-NoProfile -NonInteractive -Command),
  overridable via PFLOW_WINDOWS_SHELL.
- Skip the macOS/BSD portability rewrite and GNU-flag guards (they target
  Unix tools and would corrupt or wrongly block PowerShell commands).
- Tear down the child tree with `taskkill /T /F` and leave the process
  attached, since POSIX process groups/signals don't apply.
- Surface PowerShell-appropriate tool descriptions/schema.

POSIX behavior is unchanged. All 596 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: cover Windows PowerShell shell invocation

Make the platform check call-time (isWindows()) and export shellInvocation
so the Windows code paths are testable from a POSIX CI host. Adds tests
that the shell/bash tools target PowerShell (not /bin/sh) on win32, honor
PFLOW_WINDOWS_SHELL, skip the Unix grep -P rewrite, and surface PowerShell
guidance — guarding against a regression of issue #11.

602 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: SecFathy <kabtest91@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

error: no such file or directory, uv_spawn '/bin/sh'

1 participant