mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-10 21:23:39 +00:00
Fix Windows exec env for Docker Desktop plugin discovery
nanobot's Windows exec environment was not forwarding ProgramFiles and related variables, so docker desktop start could not discover the desktop CLI plugin and reported unknown command. Forward the missing variables and add a regression test that covers the Windows env shape.
This commit is contained in:
parent
3cc2ebeef7
commit
bfec06a2c1
@ -218,6 +218,12 @@ class ExecTool(Tool):
|
||||
"TMP": os.environ.get("TMP", f"{sr}\\Temp"),
|
||||
"PATHEXT": os.environ.get("PATHEXT", ".COM;.EXE;.BAT;.CMD"),
|
||||
"PATH": os.environ.get("PATH", f"{sr}\\system32;{sr}"),
|
||||
"APPDATA": os.environ.get("APPDATA", ""),
|
||||
"LOCALAPPDATA": os.environ.get("LOCALAPPDATA", ""),
|
||||
"ProgramData": os.environ.get("ProgramData", ""),
|
||||
"ProgramFiles": os.environ.get("ProgramFiles", ""),
|
||||
"ProgramFiles(x86)": os.environ.get("ProgramFiles(x86)", ""),
|
||||
"ProgramW6432": os.environ.get("ProgramW6432", ""),
|
||||
}
|
||||
home = os.environ.get("HOME", "/tmp")
|
||||
return {
|
||||
|
||||
@ -5,12 +5,18 @@ strategy, and sandbox behaviour per platform — without actually running
|
||||
platform-specific binaries (all subprocess calls are mocked).
|
||||
"""
|
||||
|
||||
import sys
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.agent.tools.shell import ExecTool
|
||||
|
||||
_WINDOWS_ENV_KEYS = {
|
||||
"APPDATA", "LOCALAPPDATA", "ProgramData",
|
||||
"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432",
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# _build_env
|
||||
@ -21,7 +27,10 @@ class TestBuildEnvUnix:
|
||||
def test_expected_keys(self):
|
||||
with patch("nanobot.agent.tools.shell._IS_WINDOWS", False):
|
||||
env = ExecTool()._build_env()
|
||||
assert set(env) == {"HOME", "LANG", "TERM"}
|
||||
expected = {"HOME", "LANG", "TERM"}
|
||||
assert expected <= set(env)
|
||||
if sys.platform != "win32":
|
||||
assert set(env) == expected
|
||||
|
||||
def test_home_from_environ(self, monkeypatch):
|
||||
monkeypatch.setenv("HOME", "/Users/dev")
|
||||
@ -45,6 +54,7 @@ class TestBuildEnvWindows:
|
||||
_EXPECTED_KEYS = {
|
||||
"SYSTEMROOT", "COMSPEC", "USERPROFILE", "HOMEDRIVE",
|
||||
"HOMEPATH", "TEMP", "TMP", "PATHEXT", "PATH",
|
||||
*_WINDOWS_ENV_KEYS,
|
||||
}
|
||||
|
||||
def test_expected_keys(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user