Skip to content

fix(update): add --clear flag to uv venv rebuild to prevent Windows bricking #37881#37965

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:fix/venv-rebuild-clear
Closed

fix(update): add --clear flag to uv venv rebuild to prevent Windows bricking #37881#37965
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:fix/venv-rebuild-clear

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

When hermes update triggers a venv rebuild on Windows, the running python.exe inside the venv is locked by the OS, so shutil.rmtree() silently fails to fully remove the directory. The subsequent uv venv command then fails with A directory already exists, leaving the venv in a half-deleted state (pyvenv.cfg gone, python.exe still present) which bricks the CLI with ModuleNotFoundError.

Fix: Adding --clear to the uv venv command makes it handle any leftover directory gracefully, regardless of what rmtree managed to remove. This is a one-line change in hermes_cli/managed_uv.py.

Before:

result = subprocess.run(
    [uv_bin, "venv", str(venv_dir), "--python", python_version],
    ...
)

After:

# Use --clear so uv handles any leftover directory that rmtree couldn't
# fully remove (e.g. on Windows where the running python.exe inside the
# venv is locked).  Without --clear, a partially-deleted venv causes
# "A directory already exists" and bricks the install.  See #37881.
result = subprocess.run(
    [uv_bin, "venv", str(venv_dir), "--clear", "--python", python_version],
    ...
)

Fixes #37881

…ricking

When 'hermes update' triggers a venv rebuild on Windows, the running
python.exe inside the venv is locked by the OS, so shutil.rmtree()
silently fails to fully remove the directory.  The subsequent 'uv venv'
command then fails with 'A directory already exists', leaving the venv
in a half-deleted state (pyvenv.cfg gone, python.exe still present)
which bricks the CLI with ModuleNotFoundError.

Adding --clear to the uv venv command makes it handle any leftover
directory gracefully, regardless of what rmtree managed to remove.

Fixes NousResearch#37881
@kyssta-exe kyssta-exe requested a review from a team June 3, 2026 06:30
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard python:uv Pull requests that update python:uv code labels Jun 3, 2026
@kyssta-exe

Copy link
Copy Markdown
Contributor Author

Closing in favor of a clean PR with proper base. The branch was pushed from an outdated fork, causing 4000+ file diffs.

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 P3 Low — cosmetic, nice to have python:uv Pull requests that update python:uv code type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes update bricks the install on Windows — venv rebuild leaves a venv with no pyvenv.cfg, then ModuleNotFoundError: hermes_cli

2 participants