Skip to content

Bug: HOME env corrupted inside Hermes profile runtime context — Path.home() resolves to wrong directory #25114

@Phantomthedog

Description

@Phantomthedog

Bug Report: $HOME environment variable corrupted inside Hermes profile runtime context

Description

When a Python script (or child process) runs inside a Hermes profile's session context, the $HOME environment variable is set to /path/.hermes/profiles/<profile_name>/home instead of the actual user home directory (e.g., /home/jack). This causes Path.home() in Python, os.path.expanduser("~"), and any tooling that relies on $HOME to resolve to the wrong directory.

Impact

  • All Python scripts using Path.home() break when run inside an active Hermes session
  • Scripts fail to find files under ~/.hermes/ because they look under ~/.hermes/profiles/worker/home/.hermes/
  • This affects the diff-inventory.py helper, daily_session_memory_miner.py, and any custom tooling
  • The issue is intermittent — sometimes not reproducible in a fresh terminal

Reproduction

from pathlib import Path
print(Path.home())
# Actual: /home/jack/.hermes/profiles/worker/home (WRONG)
# Expected: /home/jack

Affected Components

  • All Python skill helpers that use Path.home() to resolve Hermes paths
  • Any subprocess spawned from within a Hermes agent session

Suggested Fix

Option A — Environment invariant: Ensure $HOME is set to the real user home directory (e.g., /home/jack) before spawning agent sessions, not the profile-relative path.

Option B — Documentation: Document this quirk and recommend that all skill helpers use a fallback pattern:

_HOME = Path(os.environ.get("HOME", "/home/jack"))
if not _HOME.exists() or "worker/home" in str(_HOME) or "profiles/" in str(_HOME):
    _HOME = Path("/home/jack")
HERMES_BASE = _HOME / ".hermes"

Option C — Environment variable: Add HERMES_REAL_HOME or similar env var that always points to the actual user home regardless of profile context.

Workaround (applied locally)

All Python helpers now use the environment-robust pattern with corruption detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions