Skip to content

fix(gateway): detect .venv and venv directories for systemd unit generation#2500

Closed
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/systemd-venv-path
Closed

fix(gateway): detect .venv and venv directories for systemd unit generation#2500
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/systemd-venv-path

Conversation

@teyrebaz33

Copy link
Copy Markdown
Contributor

Fixes #2492

Root cause

get_python_path() and generate_systemd_unit() hardcoded venv/ as the virtualenv directory name. setup-hermes.sh creates .venv/ by default, so the generated systemd unit had VIRTUAL_ENV and PATH pointing to a nonexistent venv/ directory.

Fix

Add _find_venv_dir() helper that:

  1. Checks .venv/ first (setup-hermes.sh default)
  2. Falls back to venv/
  3. Falls back to sys.prefix when inside a venv (pip install -e installs)

Both get_python_path() and generate_systemd_unit() now use this helper. ExecStart was already correct (fell back to sys.executable); this fixes VIRTUAL_ENV= and PATH= in the unit file.

…ration

get_python_path() hardcoded 'venv/' but setup-hermes.sh creates '.venv/'.
This caused VIRTUAL_ENV and PATH in the generated systemd unit to point
to a nonexistent directory.

Add _find_venv_dir() that checks .venv first, then venv, then falls back
to sys.prefix (for pip install -e setups). Both get_python_path() and
generate_systemd_unit() now use this helper.

Fixes NousResearch#2492
@teknium1

Copy link
Copy Markdown
Contributor

Closed as duplicate — #2493 by @Mibayy was salvaged and merged via PR #2797 (submitted first, cleanest implementation). Thanks for the contribution @teyrebaz33!

@teknium1 teknium1 closed this Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gateway): systemd service unit hardcodes venv/ path, breaks when virtualenv is .venv

2 participants