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"), 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"