pass (a copy of) the full env to process, as we don't know what's needed

This fixes windows problem where the commands need some additional
env vars that weren't passed. In general, they also might need HOME,
USER, etc...so it's easier to just pass them all.
This commit is contained in:
Senko Rasic
2024-05-23 15:25:20 +02:00
parent e57065345a
commit 8c97cc9669

View File

@@ -2,8 +2,9 @@ import asyncio
import signal
import sys
import time
from copy import deepcopy
from dataclasses import dataclass
from os import getenv
from os import environ
from os.path import abspath, join
from typing import Callable, Optional
from uuid import UUID, uuid4
@@ -41,7 +42,7 @@ class LocalProcess:
env: dict[str, str],
bg: bool = False,
) -> "LocalProcess":
log.debug(f"Starting process: {cmd} (cwd={cwd}, env={env})")
log.debug(f"Starting process: {cmd} (cwd={cwd})")
_process = await asyncio.create_subprocess_shell(
cmd,
cwd=cwd,
@@ -147,9 +148,7 @@ class ProcessManager:
exit_handler: Optional[Callable] = None,
):
if env is None:
env = {
"PATH": getenv("PATH"),
}
env = deepcopy(environ)
self.processes: dict[UUID, LocalProcess] = {}
self.default_env = env
self.root_dir = root_dir