Skip to content

fix(gateway): keep venv python symlink unresolved in systemd unit - #8861

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-53eb8df2
Apr 13, 2026
Merged

fix(gateway): keep venv python symlink unresolved in systemd unit#8861
teknium1 merged 1 commit into
mainfrom
hermes/hermes-53eb8df2

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvage of #7735 by @akhater onto current main.

_remap_path_for_user() called .resolve() on the Python path when generating systemd units via hermes gateway install --system. On uv-managed venvs (where venv/bin/python symlinks into ~/.local/share/uv/python/...), this swapped the unit's ExecStart to the bare base interpreter — no site-packages, crashes with ModuleNotFoundError: yaml on first import, loops on Restart=on-failure.

Fix: drop .resolve(), use .expanduser() for lexical ~ expansion only. The function's purpose is purely lexical home-prefix substitution, not symlink resolution.

Only affects the --system code path (cross-user install). User-level services are unaffected.

Test plan

  • 70/70 gateway service tests pass
  • Existing TestRemapPathForUser + TestSystemUnitPathRemapping tests cover the core behavior

_remap_path_for_user was calling .resolve() on the Python path, which
followed venv/bin/python into the base interpreter. On uv-managed venvs
this swaps the systemd ExecStart to a bare Python that has none of the
venv's site-packages, so the service crashes on first import. Classical
python -m venv installs were unaffected by accident: the resolved target
/usr/bin/python3.x lives outside $HOME so the path-remap branch was
skipped and the system Python's packages silently worked.

Remove .resolve() calls on both current_home and the path; use
.expanduser() for lexical tilde expansion only. The function does
lexical prefix substitution, which is all it needs to do for its
actual purpose (remapping /root/.hermes -> /home/<user>/.hermes when
installing system services as root for a different user).

Repro: on a uv-managed venv install, `sudo hermes gateway install
--system` writes ExecStart=.../uv/python/cpython-3.11.15-.../bin/python3.11
instead of .../hermes-agent/venv/bin/python, and the service crashes on
ModuleNotFoundError: yaml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant