Skip to content

The agent that grows with you

fix(gateway): keep the venv on the Windows restart watcher

brooklyn!bfdeb644744b
diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.py
index 7d12cea0134..98cfc51906f 100644
--- a/gateway/run_shutdown.py
+++ b/gateway/run_shutdown.py
@@ -1421,6 +1421,13 @@ class GatewayShutdownMixin:
windows_detach_flags_without_breakaway, windows_detach_popen_kwargs
)
watcher_env = GatewayShutdownMixin._restart_watcher_env()
+ # host_gateway_child_env does not copy the parent dotenv. The watcher
+ # still has to run inside the venv this process is using, or the
+ # respawn cannot import hermes.
+ if not watcher_env.get("VIRTUAL_ENV"):
+ inherited = os.environ.get("VIRTUAL_ENV")
+ if inherited:
+ watcher_env["VIRTUAL_ENV"] = inherited
project_root = Path(__file__).resolve().parent.parent
# Console python under CREATE_NO_WINDOW: nothing flashes. NOT pythonw.exe — a console-less
# watcher makes every console-subsystem descendant allocate a visible conhost (#54220/#56747).