Skip to content

fix(cli): use 'uv tool upgrade' when hermes was installed via 'uv tool install' (#29700)#29707

Closed
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/29700-update-uv-tool-install
Closed

fix(cli): use 'uv tool upgrade' when hermes was installed via 'uv tool install' (#29700)#29707
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/29700-update-uv-tool-install

Conversation

@Bartok9

@Bartok9 Bartok9 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes hermes update on systems where Hermes was installed via uv tool install hermes-agent (the standard install script).

Root cause

_cmd_update_pip() always uses uv pip install --upgrade hermes-agent when uv is found. But uv pip install requires an active virtual environment, and uv tool install installs into an isolated tool environment — no activatable venv exists. The result:

→ Running: /home/user/.local/bin/uv pip install --upgrade hermes-agent
error: No virtual environment found; run `uv venv` to create an environment,
or pass --system to install into a non-virtual environment
✗ Update failed

Fix

Before choosing the update command, probe uv tool list to detect the install method:

tool_list = subprocess.run([uv, "tool", "list"], capture_output=True, text=True, timeout=15)
is_uv_tool = tool_list.returncode == 0 and "hermes-agent" in tool_list.stdout

if is_uv_tool:
    cmd = [uv, "tool", "upgrade", "hermes-agent"]   # correct for tool installs
else:
    cmd = [uv, "pip", "install", "--upgrade", "hermes-agent"]  # existing path

Fallback chain preserved: if uv tool list fails or times out (15 s), the prior uv pip install path is used. If uv isn't on PATH at all, sys.executable -m pip is used (unchanged).

The probe adds ~50 ms on the fast path (uv tool list has no network I/O).

Tests

New file tests/hermes_cli/test_cmd_update_pip_uv_tool.py — 5 cases:

Test Asserts
test_uv_tool_install_uses_uv_tool_upgrade hermes-agent in tool list → uv tool upgrade
test_no_uv_tool_install_uses_uv_pip not in tool list → uv pip install
test_tool_list_failure_falls_back_to_uv_pip tool list rc!=0 → uv pip install
test_tool_list_timeout_falls_back_to_uv_pip TimeoutExpired → uv pip install
test_no_uv_falls_back_to_pip_module no uv → sys.executable -m pip
5 passed in 1.52s

Fixes #29700

@daimon-nous daimon-nous Bot added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard python:uv Pull requests that update python:uv code labels May 21, 2026
@Bartok9

Bartok9 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing to stay within contributor PR limit. Will resubmit with fresh rebase if the issue remains open in main.

@Bartok9 Bartok9 closed this May 27, 2026
@Bartok9 Bartok9 reopened this May 27, 2026
…l install' (NousResearch#29700)

hermes update calls _cmd_update_pip() when no .git directory is found
(standard PyPI/install-script installs). It detects uv via shutil.which
and then always runs:

    uv pip install --upgrade hermes-agent

This fails with:

    error: No virtual environment found; run `uv venv` to create an
    environment, or pass --system to install into a non-virtual
    environment

because `uv pip install` requires an active venv, but the standard
install script uses `uv tool install hermes-agent` which creates its
own isolated tool environment (not a user-activatable venv).

Fix: before choosing the uv command, run `uv tool list` (with a
15 s timeout) to detect whether hermes-agent is a tool-install.

  hermes-agent in tool list  ->  uv tool upgrade hermes-agent
  not in tool list            ->  uv pip install --upgrade hermes-agent
  uv tool list fails/times out -> fall back to uv pip (prior behaviour)
  uv not found                -> sys.executable -m pip (prior behaviour)

The probe adds ~50 ms on the fast path (uv tool list is a local command
with no network I/O).

Adds 5 new tests covering:
- uv tool install path -> uv tool upgrade
- regular venv path -> uv pip install
- uv tool list rc!=0 fallback
- TimeoutExpired fallback
- no uv at all -> pip module

Fixes NousResearch#29700
@teknium1

Copy link
Copy Markdown
Contributor

Closed in favor of the consolidated fix PR #35248 (commit 4d7ea3f). It fixes the same uv-tool-install bug you reported, plus pipx and bare-system-Python layouts. Thanks for the contribution!

@teknium1 teknium1 closed this May 30, 2026
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 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.

hermes update fails when Hermes is installed via uv tool install

2 participants