Skip to content

fix(desktop/windows): stop the uv-launched gateway before recreating the venv - #53124

Closed
Cossackx wants to merge 1 commit into
NousResearch:mainfrom
Cossackx:fix/desktop-windows-stop-uv-gateway
Closed

fix(desktop/windows): stop the uv-launched gateway before recreating the venv#53124
Cossackx wants to merge 1 commit into
NousResearch:mainfrom
Cossackx:fix/desktop-windows-stop-uv-gateway

Conversation

@Cossackx

Copy link
Copy Markdown
Contributor

Problem

On Windows, install.ps1 aborts at the venv stage with a locked-file error when a Hermes gateway is running:

Cannot remove item ...\venv\Lib\site-packages\pywin32_system32\pywintypes311.dll: Access to the path '...' is denied

The venv-recreate guard already tries to stop running processes first, but it only matches:

  • taskkill /IM hermes.exe — the gateway runs as python/pythonw, not hermes.exe; and
  • processes whose ExecutablePath starts with venv\Scripts\.

uv venv installs trampoline launchers: running venv\Scripts\pythonw.exe re-execs into the uv-managed base interpreter under %APPDATA%\uv\python\…, so the live gateway's ExecutablePath is that base interpreter — not under the venv. Both filters miss it, the gateway keeps the venv's .pyd/.dll files mapped, and the venv delete fails → the whole install/update aborts (and, when triggered from the desktop bootstrap, manifests as a recurring "INSTALL DIDN'T FINISH" loop).

Fix

Before deleting the venv, also stop the gateway two robust ways:

  1. the pid it records in gateway_state.json, and
  2. any python/pythonw whose command line runs the gateway module (hermes_cli[.main] … gateway), tree-killed.

Both require the gateway to share the installer's session, so this pairs naturally with autostart tasks registered LogonType=Interactive rather than S4U/Session-0 (a Session-0 gateway is invisible to an un-elevated installer's Get-CimInstance command-line read).

Verification

  • Reproduced: with the gateway up, the existing sweep leaves it running and the venv delete fails on a locked pywintypes311.dll.
  • With the patch, the command-line filter matches the live gateway — both the venv\Scripts\pythonw.exe trampoline parent and the uv-base-python.exe child (each carrying -m hermes_cli.main gateway run); the gateway_state.json pid matches the child. Tree-killing both releases the venv and the recreate succeeds.
  • scripts/install.ps1 parses clean under the Windows PowerShell 5.1 AST parser.

🤖 Generated with Claude Code

…the venv

The venv-recreate guard in install.ps1 stops processes whose ExecutablePath is
under venv\Scripts\ (plus a taskkill of the hermes.exe image). But `uv venv`
installs TRAMPOLINE launchers: venv\Scripts\pythonw.exe re-execs into the
uv-managed base interpreter (%APPDATA%\uv\python\...), so the live gateway's
ExecutablePath is that base interpreter -- not under the venv -- and its image is
python/pythonw, not hermes.exe. Both filters miss it; the running gateway keeps
the venv's .pyd/.dll files mapped and the venv delete fails with
"Access to the path '...pywintypes311.dll' is denied", aborting the install.

Before deleting the venv, also stop the gateway two robust ways: (1) the pid it
records in gateway_state.json, and (2) any python/pythonw whose command line runs
the gateway module (hermes_cli[.main] ... gateway), tree-killed. Both require the
gateway to share the installer's session, so this pairs with autostart tasks
registered LogonType=Interactive rather than S4U/Session-0.

Verified against a live gateway: the cmdline filter matches both the
venv\Scripts\pythonw.exe trampoline parent and the uv-base-python child;
install.ps1 parses clean under the Windows PowerShell 5.1 parser.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists labels Jun 26, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the detailed Windows reproduction. This is already addressed on current main by a broader installer recovery path, so this automated hermes-sweeper review is closing it as implemented.

  • b14d75f8afdb624be03cbefd19494ccc850bf367 added gateway-task disarming, repeated process sweeping, and rename-then-delete venv replacement for locked DLL scenarios; it shipped in v2026.7.7.
  • Current scripts/install.ps1:17121730 renames the old venv before cleanup, allowing uv venv to recreate a fresh environment even if a trampoline-launched process still maps a native extension.
  • Current hermes_cli/main.py:89828991 also recognizes uv/base-interpreter trampoline holders by command line or install-root context, with scoped matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants