Skip to content

fix(install): kill venv-resident gateway before recreating venv on Windows - #46726

Closed
Danamove wants to merge 1 commit into
NousResearch:mainfrom
Danamove:fix/venv-recreate-kill-gateway-process
Closed

fix(install): kill venv-resident gateway before recreating venv on Windows#46726
Danamove wants to merge 1 commit into
NousResearch:mainfrom
Danamove:fix/venv-recreate-kill-gateway-process

Conversation

@Danamove

Copy link
Copy Markdown
Contributor

Problem

On Windows, the desktop app re-runs scripts/install.ps1 on every launch. When an update is pulled it recreates the venv. The existing guard before Remove-Item venv only does:

& taskkill /F /T /IM hermes.exe /FI "PID ne $myPid"

That misses the most common lock-holder. The gateway/agent that a scheduled task or watchdog autostarts runs as:

pythonw.exe -m hermes_cli.main gateway run    # straight out of venv\Scripts\

Its image name is python/pythonw, not hermes.exe, so taskkill /IM hermes.exe never matches it. It keeps the venv's native extensions loaded (observed on tornado\speedups.pyd; also _bcrypt.pyd), so the next line fails:

venv → FAILED: Cannot remove item ...\venv\Lib\site-packages\tornado\speedups.pyd:
Access to the path 'speedups.pyd' is denied.

The bootstrap aborts at the venv stage and the desktop never loads — even though killing the leftover gateway and relaunching fixes it every time.

Fix

Keep the existing hermes.exe taskkill, and additionally stop any process whose executable lives under the venv being deleted, matched by path (ExecutablePath -like "$venvRoot\*") so:

  • the image name is irrelevant (python.exe / pythonw.exe / hermes.exe all caught), and
  • a global/system Python outside the venv is never touched, and the installer's own PID is excluded.

Scoped to Install-Venv, Windows-only, no behavior change on other platforms.

Test

  • [System.Management.Automation.Language.Parser]::ParseFile(...) → parses cleanly.
  • Reproduced the original failure on a live install (gateway autostarted from venv\Scripts\pythonw.exe locking speedups.pyd); with the leftover venv-resident process stopped, Remove-Item venv and the full bootstrap (venv → dependencies → … → ready) complete.

🤖 Generated with Claude Code

…ndows)

The Windows venv-recreate guard only runs `taskkill /IM hermes.exe`, but the
gateway that a scheduled task or watchdog autostarts runs as
`pythonw.exe -m hermes_cli.main gateway run` straight out of venv\Scripts\.
Its image name is python/pythonw, so taskkill never matches it; it keeps the
venv's native extensions (e.g. tornado\speedups.pyd) loaded, and the following
Remove-Item fails with "Access to the path is denied" -- aborting boot at the
venv stage so the desktop app never loads.

Additionally stop any process whose executable lives under this venv, matched
by path so the image name is irrelevant and a global/system python outside the
venv is never touched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jquesnelle

Copy link
Copy Markdown
Collaborator

Superseded by #52044

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

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants