Skip to content

Hermes provider inherits PYTHONPATH and fails to start bm MCP with mixed Python versions #1093

Description

@tellus1019

Summary

The Hermes Basic Memory provider passes the full Hermes backend environment to the bm mcp subprocess.

Hermes Desktop adds its Python 3.11 site-packages to PYTHONPATH, while the Basic Memory uv tool runs on Python 3.12. The child process therefore imports Hermes's Python 3.11 version of pydantic and fails to start.

Environment

  • macOS
  • Hermes Agent v0.18.2
  • Hermes Python 3.11.15
  • Basic Memory 0.22.1
  • Basic Memory Python 3.12
  • Hermes integration: integrations/hermes

Error

ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

The imported pydantic path is under the Hermes Python 3.11 virtual environment, while bm is running from the uv-managed Basic Memory Python 3.12 environment.

Reproduction

Running bm with the inherited Hermes environment fails:

~/.local/bin/bm --version

Running it after removing the parent Python environment succeeds:

env -u PYTHONPATH -u PYTHONHOME -u VIRTUAL_ENV ~/.local/bin/bm --version

A diagnostic Hermes provider initialization with those variables removed also succeeds and discovers 23 MCP tools.

Suspected cause

integrations/hermes/__init__.py uses:

self._env = dict(env) if env is not None else os.environ.copy()

The external bm process should not inherit Hermes's Python environment.

Suggested scope

Use a sanitized child-process environment for:

  • bm mcp
  • uv tool install basic-memory
  • bm project add

At minimum, remove:

  • PYTHONPATH
  • PYTHONHOME
  • VIRTUAL_ENV

Please include an integration test with a deliberately contaminated PYTHONPATH, since unit mocks do not reproduce the native-extension ABI failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions