fix: Matrix bridge ModuleNotFoundError - install deps to venv with persistence #2
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/matrix-bridge-dependencies"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Users connecting via Matrix bridge receive this error:
The Hermes gateway fails to start because required Python dependencies (
openai,matrix-nio) are not installed in the runtime environment.Root Cause Analysis
The Hermes agent uses an isolated virtual environment at
/opt/hermes/.venvfor dependency management. The previous compose configuration had two critical issues:Wrong installation target: The entrypoint installed packages to the system Python (
pip install), but the gateway runs from the isolated venv (/opt/hermes/.venv/bin/hermes)Ephemeral venv: Even if packages were installed to the venv correctly, the venv directory was not persisted. Container restarts would wipe all installed dependencies.
Solution
1. Install to correct environment using
uvChanged entrypoint from:
To:
Why
uv? Hermes uses astral-sh'suvas the modern Python package manager (faster, more reliable than pip).Why
--system? Required flag when installing into an active virtual environment from a script context.Why
matrix-nio[encryption]? Hermes uses thematrix-nioasyncio SDK (not mautrix). The[encryption]extra enables Olm protocol for E2EE room support.2. Persist venv to host storage
Added new volume mount:
This ensures installed packages survive container restarts and rebuilds.
Testing & Verification
After deployment, verify with:
Expected output:
OKThen test Matrix connection - the ModuleNotFoundError should be resolved.
Deployment Notes
This change requires container recreation (not just restart). On NixOS with declarative Docker stacks:
The
reloadTriggersmechanism indocker_manager.nixdetects the compose.yml hash change and recreates the container automatically.Related
fix: Add openai and matrix-nio dependencies for Hermes Matrix bridgeto fix: Matrix bridge ModuleNotFoundError - install deps to venv with persistence@Hermes this rp need to be updated. Dont create a new persistent volume. Instead, add the requirements to de custom hermes dockerfile we have now.