fix: use absolute() instead of resolve() in _remap_path_for_user to preserve venv symlinks - #8551
Closed
nurgeldy wants to merge 2 commits into
Closed
fix: use absolute() instead of resolve() in _remap_path_for_user to preserve venv symlinks#8551nurgeldy wants to merge 2 commits into
nurgeldy wants to merge 2 commits into
Conversation
…reserve venv symlinks Path.resolve() follows symlinks, which converts venv Python paths (venv/bin/python -> /uv/python/...) before the prefix remapping logic runs. When installing a system service via sudo, this causes the generated ExecStart to point to the bare system Python (no packages) instead of the venv Python, resulting in ModuleNotFoundError for dependencies like pyyaml. Path.absolute() converts relative paths to absolute without following symlinks, preserving the venv Python path through the remap.
…is absent hermes status only checked systemctl --user is-active for the user service. Servers running the system service (--system) always showed stopped. Now checks both user and system services, reporting whichever is active.
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.
Problem
When installing a system gateway service via
sudo hermes gateway install --system, the generatedExecStartpoints to the bare system Python instead of the venv Python. This causesModuleNotFoundError(e.g.No module named 'yaml') because the system Python doesn't have project dependencies installed.Root Cause
_remap_path_for_user()inhermes_cli/gateway.pyusesPath(path).resolve()which follows symlinks. The venv Python (venv/bin/python) is typically a symlink to the system Python binary. Afterresolve(), the symlink target replaces the venv path. Since the resolved path lives under a different prefix than the current user's home, the remap returns it as-is — losing the venv context entirely.Flow:
get_python_path()correctly detectsvenv/bin/python_remap_path_for_user(python_path, home_dir)callsPath(python_path).resolve()/usr/local/share/uv/python/cpython-3.11-.../bin/python3.11/root/, so remap returns it unchangedFix
Path.absolute()converts relative paths to absolute without following symlinks. This preserves the venv Python path through the remapping logic.Verification
After the fix,
sudo hermes gateway install --systemgenerates:Instead of the previous broken output: