Skip to content

fix(gateway): dynamically detect virtualenv path in systemd unit generation (#2492)#2518

Closed
devorun wants to merge 1 commit into
NousResearch:mainfrom
devorun:patch-4
Closed

fix(gateway): dynamically detect virtualenv path in systemd unit generation (#2492)#2518
devorun wants to merge 1 commit into
NousResearch:mainfrom
devorun:patch-4

Conversation

@devorun

@devorun devorun commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

…ration (#2492)

What does this PR do?

Fixes the hardcoded venv/ directory reference in hermes_cli/gateway.py when generating the systemd unit. It dynamically detects the active virtual environment using sys.prefix and properly checks for .venv as a fallback, preventing PATH and VIRTUAL_ENV from pointing to a nonexistent directory.

Related Issue

Fixes #2492

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)

Changes Made

  • Updated get_python_path() to dynamically check for both .venv and venv.
  • Updated generate_systemd_unit() to prioritize sys.prefix and fallback to existing virtual environments instead of hardcoding venv/.

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • My PR contains only changes related to this fix

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

…ration (NousResearch#2492)

## What does this PR do?
Fixes the hardcoded `venv/` directory reference in `hermes_cli/gateway.py` when generating the systemd unit. It dynamically detects the active virtual environment using `sys.prefix` and properly checks for `.venv` as a fallback, preventing `PATH` and `VIRTUAL_ENV` from pointing to a nonexistent directory.

## Related Issue
Fixes NousResearch#2492

## Type of Change
- [x] 🐛 Bug fix (non-breaking change that fixes an issue)
- [ ] ✨ New feature (non-breaking change that adds functionality)

## Changes Made
- Updated `get_python_path()` to dynamically check for both `.venv` and `venv`.
- Updated `generate_systemd_unit()` to prioritize `sys.prefix` and fallback to existing virtual environments instead of hardcoding `venv/`.

## Checklist
- [x] I've read the Contributing Guide
- [x] My commit messages follow Conventional Commits
- [x] My PR contains only changes related to this fix
@devorun devorun changed the title fix(gateway): dynamically detect virtualenv path in systemd unit gene… fix(gateway): dynamically detect virtualenv path in systemd unit generation (#2492) Mar 22, 2026
@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 @devorun!

@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