mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(docker): hermes update prints docker pull guidance instead of bogus git error
Inside the published Docker image, `hermes update` was hitting the
".git missing → reinstall via curl" fallback:
✗ Not a git repository. Please reinstall:
curl -fsSL https://raw.githubusercontent.com/.../install.sh | bash
That message is wrong on two counts:
1. It tells the user to run the host-side installer, which would
install a *new* Hermes on the host — not update the running
container.
2. It doesn't mention `docker pull` at all, leaving Docker users
to figure out the right action from scratch.
`hermes update --check` was worse: it bailed with "Not a git
repository — cannot check for updates." and nothing else.
Fix: detect the Docker install method (already stamped by
`docker/stage2-hook.sh` and surfaced by `detect_install_method()`)
in both update entry points and print a long-form message that
covers:
- The right command: `docker pull nousresearch/hermes-agent:latest`
- Restart guidance (`docker compose up -d --force-recreate` /
re-run `docker run`)
- How to verify the new version after restart
- Tag-pinning caveat (`:latest` doesn't move a pinned tag)
- Config persistence across upgrades (state under `HERMES_HOME` /
`/opt/data` is bind-mounted and survives)
- Fork escape hatch (build your own image with the repo's Dockerfile)
Exit code is 1 (matches `managed_error` semantic for "tried to
update but can't update this way").
Plumbing:
- hermes_cli/config.py: new `format_docker_update_message()` helper
sits next to the existing `_NIX_UPDATE_MSG` /
`format_managed_message()` family so the wording lives in one
place and both call sites (apply path + check path) consume it.
- hermes_cli/main.py:
* `cmd_update()`: bail right after the `is_managed()` gate, before
any of the apply-path branches.
* `_cmd_update_check()`: bail at the top of the function, before
the existing `method == "pip"` branch.
Neither path touches subprocess.run / git when method == "docker".
Coverage:
- 7 new tests in `tests/hermes_cli/test_cmd_update_docker.py`:
* `hermes update` in Docker → message + exit 1, no git calls
* `hermes update --check` (via cmd_update) → same
* `--yes` / `--force` don't bypass (intentional)
* `_cmd_update_check` called directly → bails too
* git/pip installs still take their normal paths (regression guards)
* `format_docker_update_message` content-lock test pinning the
five user-actionable bits the message must contain
- Existing test_cmd_update.py (21 tests) + test_managed_installs.py
(5 tests) still pass — no regression on the source-install path.
- Verified end-to-end in a real container: `docker run ... update`
and `docker run ... update --check` both render the message and
exit 1.
This commit is contained in:
parent
4a6f1863ac
commit
b924b22a9d
3 changed files with 249 additions and 1 deletions
|
|
@ -345,6 +345,58 @@ def recommended_update_command() -> str:
|
|||
return recommended_update_command_for_method(method)
|
||||
|
||||
|
||||
# Long-form text for ``hermes update`` / ``--check`` when running inside the
|
||||
# Docker image. Surfaced by ``cmd_update`` and ``_cmd_update_check`` in
|
||||
# hermes_cli/main.py; lives here so the wording stays consistent and we
|
||||
# don't grow two slightly-different copies.
|
||||
#
|
||||
# Why this matters:
|
||||
# - The published image excludes ``.git`` (see .dockerignore), so the
|
||||
# git-based update path can never succeed inside the container.
|
||||
# - The pre-existing fallback message ("✗ Not a git repository. Please
|
||||
# reinstall: curl ... install.sh") is actively misleading inside Docker
|
||||
# — that script installs a *new* host-side Hermes, it doesn't update
|
||||
# the running container.
|
||||
# - The right action is ``docker pull`` + restart the container; this
|
||||
# helper spells that out, with notes on tag pinning and config
|
||||
# persistence so users don't get blindsided.
|
||||
_DOCKER_UPDATE_MESSAGE = """\
|
||||
✗ ``hermes update`` doesn't apply inside the Docker container.
|
||||
|
||||
Hermes Agent runs as a published image (nousresearch/hermes-agent), not a
|
||||
git checkout — the container has no working tree to pull into. Update by
|
||||
pulling a fresh image and restarting your container instead:
|
||||
|
||||
docker pull nousresearch/hermes-agent:latest
|
||||
# then restart whatever started the container, e.g.:
|
||||
docker compose up -d --force-recreate hermes-agent
|
||||
# or, for ad-hoc runs, exit the current container and `docker run` again
|
||||
|
||||
Verify the new version after restart:
|
||||
docker run --rm nousresearch/hermes-agent:latest --version
|
||||
|
||||
Notes:
|
||||
• If you pinned a specific tag (e.g. ``:v0.14.0``) the ``:latest`` tag
|
||||
won't move your container — pull the newer tag you actually want, or
|
||||
switch to ``:latest`` / ``:main`` for rolling updates. See available
|
||||
tags at https://hub.docker.com/r/nousresearch/hermes-agent/tags
|
||||
• Your config and session history live under ``$HERMES_HOME`` (``/opt/data``
|
||||
in the container, typically bind-mounted from the host) and persist
|
||||
across image upgrades — re-pulling doesn't lose any state.
|
||||
• Running a fork? Build your own image with this repo's ``Dockerfile``
|
||||
and replace the ``docker pull`` step with your build/push pipeline."""
|
||||
|
||||
|
||||
def format_docker_update_message() -> str:
|
||||
"""Return the user-facing message for ``hermes update`` inside Docker.
|
||||
|
||||
Centralised so ``cmd_update`` (the apply path) and ``_cmd_update_check``
|
||||
(the dry-run path) share the same wording. See ``_DOCKER_UPDATE_MESSAGE``
|
||||
above for the full rationale.
|
||||
"""
|
||||
return _DOCKER_UPDATE_MESSAGE
|
||||
|
||||
|
||||
def format_managed_message(action: str = "modify this Hermes installation") -> str:
|
||||
"""Build a user-facing error for managed installs."""
|
||||
managed_system = get_managed_system() or "a package manager"
|
||||
|
|
|
|||
|
|
@ -8416,6 +8416,14 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):
|
|||
"""
|
||||
from hermes_cli.config import detect_install_method
|
||||
method = detect_install_method(PROJECT_ROOT)
|
||||
if method == "docker":
|
||||
# Docker can't ``git fetch`` from within the container. Surface the
|
||||
# same long-form ``docker pull`` guidance ``hermes update`` (apply
|
||||
# path) uses — telling the user to "reinstall via curl" or that
|
||||
# ".git is missing" would point them at the wrong remediation.
|
||||
from hermes_cli.config import format_docker_update_message
|
||||
print(format_docker_update_message())
|
||||
sys.exit(1)
|
||||
if method == "pip":
|
||||
from hermes_cli.config import recommended_update_command
|
||||
from hermes_cli.banner import check_via_pypi
|
||||
|
|
@ -8716,12 +8724,27 @@ def cmd_update(args):
|
|||
runs the update, then restores stdio on the way out (even on
|
||||
``sys.exit`` or unhandled exceptions).
|
||||
"""
|
||||
from hermes_cli.config import is_managed, managed_error
|
||||
from hermes_cli.config import (
|
||||
detect_install_method,
|
||||
format_docker_update_message,
|
||||
is_managed,
|
||||
managed_error,
|
||||
)
|
||||
|
||||
if is_managed():
|
||||
managed_error("update Hermes Agent")
|
||||
return
|
||||
|
||||
# Docker users can't ``git pull`` — the image excludes ``.git`` from
|
||||
# the build context. Bail with a friendly explanation pointing at
|
||||
# ``docker pull`` BEFORE any of the apply-path / check-path branches
|
||||
# below get a chance to error out with misleading "Not a git
|
||||
# repository" text. See format_docker_update_message() for the full
|
||||
# rationale and tag-pinning / config-persistence notes.
|
||||
if detect_install_method(PROJECT_ROOT) == "docker":
|
||||
print(format_docker_update_message())
|
||||
sys.exit(1)
|
||||
|
||||
if getattr(args, "check", False):
|
||||
# --check honors --branch so the "any new commits?" answer matches
|
||||
# what a subsequent `hermes update --branch=<x>` would actually pull.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue