Skip to content

fix(gateway): preserve launchd Hermes home on reinstall#32795

Open
gauravsaxena1997 wants to merge 1 commit into
NousResearch:mainfrom
gauravsaxena1997:bugfix/preserve-launchd-hermes-home
Open

fix(gateway): preserve launchd Hermes home on reinstall#32795
gauravsaxena1997 wants to merge 1 commit into
NousResearch:mainfrom
gauravsaxena1997:bugfix/preserve-launchd-hermes-home

Conversation

@gauravsaxena1997

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the macOS LaunchAgent reinstall path so hermes gateway install no longer silently resets an existing service from a custom HERMES_HOME back to the current shell/default Hermes home.

The fix reads service-scoped values from the existing plist before regenerating it, then preserves:

  • EnvironmentVariables.HERMES_HOME
  • EnvironmentVariables.PATH
  • EnvironmentVariables.VIRTUAL_ENV
  • StandardOutPath
  • StandardErrorPath

This keeps the repair/reinstall behavior intact while preventing an existing custom gateway home, path, venv, or log target from being overwritten by the caller's current environment. The stale-plist comparison also uses those preserved values so a valid custom-home plist does not keep looking outdated forever.

Related Issue

Fixes #32741

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

  • hermes_cli/gateway.py: add plist parsing for existing launchd service values and preserve those values during plist comparison, refresh, and force reinstall.
  • tests/hermes_cli/test_gateway_service.py: add regression coverage for reinstalling an outdated LaunchAgent plist while preserving custom HERMES_HOME, PATH, VIRTUAL_ENV, stdout log path, and stderr log path.

How to Test

  1. Install gateway once with a custom HERMES_HOME.
  2. Run hermes gateway install later from an environment where HERMES_HOME is unset or different.
  3. Verify the installed plist still points at the original custom service values.

Automated verification run locally:

scripts/run_tests.sh tests/hermes_cli/test_gateway_service.py -- -q -k launchd
uv run ruff check .
python scripts/check-windows-footguns.py --all
git diff --check

Results:

  • launchd slice: 14 passed
  • ruff: passed
  • Windows footgun scan: passed
  • whitespace check: passed

I also tried the full tests/hermes_cli/test_gateway_service.py file on macOS. The launchd tests passed, but six unrelated systemd tests fail on current upstream/main before this patch's launchd path because _preflight_user_systemd() rejects the local non-Linux D-Bus/systemd environment.

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
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS

Documentation & Housekeeping

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

Screenshots / Logs

Not applicable. This is covered by launchd plist regression tests.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels May 26, 2026
@gauravsaxena1997 gauravsaxena1997 force-pushed the bugfix/preserve-launchd-hermes-home branch from 0e42fdc to 52ab7ad Compare June 1, 2026 08:11
@gauravsaxena1997

Copy link
Copy Markdown
Contributor Author

Refreshed this branch onto current main so the PR is no longer conflict/dirty. Local verification after rebase:\n\n- .venv/bin/python -m pytest tests/hermes_cli/test_gateway_service.py::TestLaunchdServiceRecovery -q\n\nResult: 11 passed.

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 comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hermes gateway install silently resets HERMES_HOME on macOS LaunchAgent

2 participants