Skip to content

fix: resolve full PowerShell path on Windows#1703

Open
elis132 wants to merge 2 commits intoMoonshotAI:mainfrom
elis132:fix/windows-shell-path
Open

fix: resolve full PowerShell path on Windows#1703
elis132 wants to merge 2 commits intoMoonshotAI:mainfrom
elis132:fix/windows-shell-path

Conversation

@elis132
Copy link
Copy Markdown

@elis132 elis132 commented Apr 1, 2026

Problem

The Shell tool is completely broken on Windows when installed via uv tool install. Every shell command fails with:

[WinError 2] The system cannot find the file specified

environment.py sets shell_path = KaosPath("powershell.exe") — a bare filename. When asyncio.create_subprocess_exec() tries to launch it, CreateProcessW cannot find powershell.exe because the uv virtual environment PATH does not include C:\Windows\System32\WindowsPowerShell\v1.0\.

Fix

Resolve the full path using the SystemRoot environment variable (always set on Windows):

system_root = os.environ.get("SystemRoot", r"C:\Windows")
shell_path = KaosPath(
    os.path.join(system_root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
)

Verification

import asyncio

async def test():
    # FAILS - bare name
    await asyncio.create_subprocess_exec("powershell.exe", "-command", "echo hello", ...)
    # [WinError 2]

    # WORKS - full path
    await asyncio.create_subprocess_exec(
        r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-command", "echo hello", ...
    )

asyncio.run(test())

Fixes #1702


Open with Devin

The bare `powershell.exe` filename fails with `[WinError 2]` when
`asyncio.create_subprocess_exec` cannot find it on PATH (common in
uv tool virtual environments). Use `%SystemRoot%` to build the full
path, which works on any standard Windows installation.

Fixes MoonshotAI#1702
devin-ai-integration[bot]

This comment was marked as resolved.

Update test_environment_detection_windows to expect the full
PowerShell path and monkeypatch SystemRoot for deterministic results.
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.

Shell tool broken on Windows: [WinError 2] powershell.exe not found

1 participant