fix(gateway): detect virtualenv path instead of hardcoding venv/#2493
Closed
Mibayy wants to merge 1 commit into
Closed
fix(gateway): detect virtualenv path instead of hardcoding venv/#2493Mibayy wants to merge 1 commit into
Mibayy wants to merge 1 commit into
Conversation
Fixes NousResearch#2492. `generate_systemd_unit()` and `get_python_path()` hardcoded `venv` as the virtualenv directory name. When the virtualenv is `.venv` (which `setup-hermes.sh` and `.gitignore` both reference), the generated systemd unit had incorrect VIRTUAL_ENV and PATH variables. Introduce `_detect_venv_dir()` which: 1. Checks `sys.prefix` vs `sys.base_prefix` to detect the active venv 2. Falls back to probing `.venv` then `venv` under PROJECT_ROOT Both `get_python_path()` and `generate_systemd_unit()` now use this detection instead of hardcoded paths.
This was referenced Mar 24, 2026
Closed
Contributor
This was referenced Mar 24, 2026
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.
Fixes #2492.
Problem
generate_systemd_unit()andget_python_path()inhermes_cli/gateway.pyhardcodevenvas the virtualenv directory name. When the virtualenv is created as.venv(whichsetup-hermes.shand.gitignoreboth reference), the generated systemd unit has incorrectVIRTUAL_ENVandPATHenvironment variables pointing to a nonexistentvenv/directory.Solution
Introduce
_detect_venv_dir()which:sys.prefixvssys.base_prefixto detect the active virtualenv (works regardless of directory name).venvthenvenvunderPROJECT_ROOTNonewhen no virtualenv is foundBoth
get_python_path()andgenerate_systemd_unit()now use this detection instead of hardcoded paths.Tests
Added tests for:
_detect_venv_dir(): sys.prefix detection, .venv fallback, venv fallback, .venv preferred over venv, no venv returns Nonegenerate_systemd_unit(): verifies the unit file uses the detected venv path