Skip to content

fix(gateway): honor explicit HERMES_HOME in systemd install#6941

Closed
bobashopcashier wants to merge 1 commit into
NousResearch:mainfrom
bobashopcashier:fix/6729-systemd-hermes-home
Closed

fix(gateway): honor explicit HERMES_HOME in systemd install#6941
bobashopcashier wants to merge 1 commit into
NousResearch:mainfrom
bobashopcashier:fix/6729-systemd-hermes-home

Conversation

@bobashopcashier

@bobashopcashier bobashopcashier commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Preserves an explicitly configured HERMES_HOME when generating Linux systemd gateway units, including the common sudo case where the current process environment no longer carries the target user's custom Hermes home.

Related Issue

Fixes #6729
Related to #5947, but intentionally limited to the systemd gateway install path

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • updated hermes_cli/gateway.py to preserve explicit HERMES_HOME and probe the target user's login environment before falling back to the existing remap/default logic
  • preserved the current explicit-env remap behavior for /root/.hermes and /root/.hermes/profiles/<name> sudo cases
  • added regression coverage in tests/hermes_cli/test_gateway_service.py for explicit env precedence, probed custom/profile homes, and empty-probe fallback
  • kept this branch limited to the systemd install fix instead of bundling separate env/pairing hardening

How to Test

  1. Run /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_gateway_service.py -q
  2. Run hermes gateway install --system with a non-default HERMES_HOME under sudo and confirm the generated unit uses that home
  3. Repeat without an explicit custom home and confirm the existing fallback behavior remains unchanged

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_gateway_service.py -q54 passed

@bobashopcashier bobashopcashier force-pushed the fix/6729-systemd-hermes-home branch from 8847285 to c19fbb4 Compare April 10, 2026 06:33
@teknium1

Copy link
Copy Markdown
Contributor

Closing — the core issue (system service paths not remapped under sudo) was addressed in commit 8dd738c which added _remap_path_for_user() to remap ExecStart, WorkingDirectory, VIRTUAL_ENV, and PATH to the target user's home. The existing _hermes_home_for_target_user() handles the default ~/.hermes remapping. Thanks for the thorough approach though — the login-shell probe would cover custom HERMES_HOME paths, but that's a narrow edge case now.

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.

[Bug]: Systemd Gateway installation does not honor non-standard HERMES_HOME env variable

2 participants