Description
generate_systemd_unit() and get_python_path() in hermes_cli/gateway.py hardcode venv as the virtualenv directory name. When the virtualenv is created as .venv (which setup-hermes.sh and .gitignore both reference), the generated systemd unit has incorrect VIRTUAL_ENV and PATH environment variables pointing to a nonexistent venv/ directory.
Impact
ExecStart works correctly because get_python_path() falls back to sys.executable when venv/bin/python doesn't exist
- But
VIRTUAL_ENV and PATH in the unit file point to PROJECT_ROOT/venv/ which doesn't exist
- This can cause subprocesses, tools, or pip invocations within the gateway to resolve incorrectly
Steps to Reproduce
- Install hermes-agent with
.venv as the virtualenv directory name
- Run
hermes gateway install
- Inspect the generated unit file at
~/.config/systemd/user/hermes-gateway.service
- Observe
VIRTUAL_ENV and PATH reference venv/ instead of .venv/
Suggested Fix
In hermes_cli/gateway.py:
get_python_path() (lines 376-378): check for both .venv and venv
generate_systemd_unit() (lines 402-403): detect the actual virtualenv directory instead of hardcoding venv
- Simplest approach: use
sys.prefix to get the active virtualenv path at install time
Environment
- OS: Ubuntu 22.04 on WSL2
- Python: 3.11.13
- Hermes Agent: v0.4.0
Description
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.Impact
ExecStartworks correctly becauseget_python_path()falls back tosys.executablewhenvenv/bin/pythondoesn't existVIRTUAL_ENVandPATHin the unit file point toPROJECT_ROOT/venv/which doesn't existSteps to Reproduce
.venvas the virtualenv directory namehermes gateway install~/.config/systemd/user/hermes-gateway.serviceVIRTUAL_ENVandPATHreferencevenv/instead of.venv/Suggested Fix
In
hermes_cli/gateway.py:get_python_path()(lines 376-378): check for both.venvandvenvgenerate_systemd_unit()(lines 402-403): detect the actual virtualenv directory instead of hardcodingvenvsys.prefixto get the active virtualenv path at install timeEnvironment