fix(cli-apps): preserve XDG_RUNTIME_DIR for desktop CLIs

This commit is contained in:
KevinAndrewDong authored and chengyongru committed 2026-10-04 15:03:35 +08:00
1 parent 13cec0146d
commit acdae3d0ae
3 files changed
+68 -3

No files matched your search

+6 -2
View File
@@ -993,7 +993,7 @@ class CliAppManager:
def _subprocess_env(self) -> dict[str, str]:
"""Minimal env for CLI app subprocesses — no API keys or secrets.
Mirrors the shell tool's allowlist so installed apps cannot read
Uses an explicit allowlist so installed apps cannot read
provider credentials from the parent process environment.
"""
if sys.platform == "win32":
@@ -1011,13 +1011,17 @@ class CliAppManager:
"PYTHONUNBUFFERED": "1",
}
return env
return {
env = {
"HOME": os.environ.get("HOME", "/tmp"),
"LANG": os.environ.get("LANG", "C.UTF-8"),
"TERM": os.environ.get("TERM", "dumb"),
"PATH": os.environ.get("PATH", "/usr/bin:/bin"),
"PYTHONUNBUFFERED": "1",
}
# Desktop CLIs use this directory to locate the running application.
if "XDG_RUNTIME_DIR" in os.environ:
env["XDG_RUNTIME_DIR"] = os.environ["XDG_RUNTIME_DIR"]
return env
def _run_argv(self, argv: list[str], *, timeout: int) -> subprocess.CompletedProcess[str]:
command = subprocess.list2cmdline(argv)