From d3ad7d0b71bf57ca0d82b49ae1d7c8aed9ac6201 Mon Sep 17 00:00:00 2001 From: Elis Date: Wed, 1 Apr 2026 15:10:33 +0200 Subject: [PATCH 1/2] fix: resolve full PowerShell path on Windows to prevent WinError 2 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 #1702 --- src/kimi_cli/utils/environment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kimi_cli/utils/environment.py b/src/kimi_cli/utils/environment.py index 6b4bb78ad..520636af9 100644 --- a/src/kimi_cli/utils/environment.py +++ b/src/kimi_cli/utils/environment.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import platform from dataclasses import dataclass from typing import Literal @@ -32,7 +33,10 @@ async def detect() -> Environment: if os_kind == "Windows": shell_name = "Windows PowerShell" - shell_path = KaosPath("powershell.exe") + system_root = os.environ.get("SystemRoot", r"C:\Windows") + shell_path = KaosPath( + os.path.join(system_root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") + ) else: possible_paths = [ KaosPath("/bin/bash"), From a0241f3fb6ea344de6dc3850e35241ca61d7eeb6 Mon Sep 17 00:00:00 2001 From: Elis Date: Wed, 1 Apr 2026 15:21:48 +0200 Subject: [PATCH 2/2] test: update Windows shell path assertion to match full path Update test_environment_detection_windows to expect the full PowerShell path and monkeypatch SystemRoot for deterministic results. --- tests/utils/test_utils_environment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_utils_environment.py b/tests/utils/test_utils_environment.py index abb3a4ae4..c367c14ed 100644 --- a/tests/utils/test_utils_environment.py +++ b/tests/utils/test_utils_environment.py @@ -30,6 +30,7 @@ async def test_environment_detection_windows(monkeypatch): monkeypatch.setattr(platform, "system", lambda: "Windows") monkeypatch.setattr(platform, "machine", lambda: "AMD64") monkeypatch.setattr(platform, "version", lambda: "10.0.19044") + monkeypatch.setenv("SystemRoot", r"C:\Windows") from kimi_cli.utils.environment import Environment @@ -38,4 +39,4 @@ async def test_environment_detection_windows(monkeypatch): assert env.os_arch == "AMD64" assert env.os_version == "10.0.19044" assert env.shell_name == "Windows PowerShell" - assert str(env.shell_path) == "powershell.exe" + assert str(env.shell_path) == r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"