fix: preserve installed systemd context on gateway restart --system - #8840
Closed
xiamulo wants to merge 2 commits into
Closed
fix: preserve installed systemd context on gateway restart --system#8840xiamulo wants to merge 2 commits into
xiamulo wants to merge 2 commits into
Conversation
added 2 commits
April 13, 2026 14:43
Avoid resolving the virtualenv interpreter symlink while remapping paths for systemd units. Resolving the link collapsed venv/bin/python into uv's shared interpreter under ~/.local/share/uv, which caused restart --system to regenerate ExecStart outside the project venv and miss installed dependencies. Add regression tests covering the lexical remap behavior and the root/system-service ExecStart generation path.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Description
gateway restart --systemcould decide that an installed systemd unit was stale using the current CLI process environment instead of the installed unit's own context, and then rewrite the unit with the wrong runtime paths.In practice this meant a valid service installed for another user could be "refreshed" into a broken unit, including a bad
ExecStartsuch as a resolved uv shared interpreter path.Root Cause
The system-service freshness check and refresh path regenerated expected unit content from the current process environment (
WorkingDirectory,VIRTUAL_ENV,HERMES_HOME, python path), rather than from the installed unit file being checked/refreshed.That made
gateway restart --systemcompare against the wrong context and rewrite the unit with incorrect paths.Fix
WorkingDirectoryandEnvironment=valuesExecStartHow to Verify
WorkingDirectory/VIRTUAL_ENVpoint to a non-current environment.gateway restart --systemfrom a different environment/user context.ExecStartis repaired using the installed unit's venv path.Test Plan
Commands run:
Risk Assessment
Low — changes are scoped to systemd unit comparison/refresh for system services, and non-system behavior keeps the previous call path for compatibility.