Skip to content

fix(gateway): remap HERMES_HOME to target user in system service unit - #4456

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-79b25268
Apr 1, 2026
Merged

fix(gateway): remap HERMES_HOME to target user in system service unit#4456
teknium1 merged 1 commit into
mainfrom
hermes/hermes-79b25268

Conversation

@teknium1

@teknium1 teknium1 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of #4447 by @deankerr onto current main.

When sudo hermes gateway install --system --run-as-user <user> generates the systemd unit, get_hermes_home() resolves to /root/.hermes because Path.home() returns root's home under sudo. The unit correctly sets HOME= and User= via _system_service_identity(), but HERMES_HOME= was computed independently and pointed to root's config directory.

Adds _hermes_home_for_target_user() which remaps the current HERMES_HOME to the equivalent path under the target user's home:

  • Default ~/.hermes → target user's ~/.hermes
  • Profiles (~/.hermes/profiles/coder) → preserves relative structure under target user
  • Custom paths (/opt/hermes) → kept as-is

Supersedes #3861 which only handled the default case and left profiles broken.

Test results

  • 36/36 test_gateway_service.py tests pass (8 new)
  • 18/18 test_gateway.py + test_gateway_linger.py pass
  • E2E verified: default, profile, and custom path remapping all correct

When `sudo hermes gateway install --system --run-as-user <user>` generates
the systemd unit, get_hermes_home() resolves to /root/.hermes because
Path.home() returns root's home under sudo. The unit correctly sets
HOME= and User= via _system_service_identity(), but HERMES_HOME was
computed independently and pointed to root's config directory.

Add _hermes_home_for_target_user() which remaps the current HERMES_HOME
to the equivalent path under the target user's home. This handles:
- Default ~/.hermes → target user's ~/.hermes
- Profiles (e.g. ~/.hermes/profiles/coder) → preserves relative structure
- Custom paths (e.g. /opt/hermes) → kept as-is

Supersedes #3861 which only handled the default case and left profiles
broken (also flagged by Copilot review).

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.

2 participants