hermes - ✅(Solved) Fix Bug: HOME env corrupted inside Hermes profile runtime context — Path.home() resolves to wrong directory [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#25114Fetched 2026-05-14 03:48:48
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1

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.

Root Cause

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

Fix Action

Fix / Workaround

Workaround (applied locally)

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

PR fix notes

PR #25151: fix(agent): expose HERMES_REAL_HOME in subprocess envs for profile isolation

Description (problem / solution / changelog)

Summary

When profile isolation is active ({HERMES_HOME}/home/ exists), child processes receive HOME={HERMES_HOME}/home/ for tool config isolation (git, ssh, gh, npm). However, scripts using Path.home() to locate ~/.hermes/ would incorrectly resolve to the isolated profile home, breaking helpers and custom tooling.

Before

# In execute_code subprocess:
import os
from pathlib import Path
print(Path.home())
# => /home/user/.hermes/profiles/worker/home  (WRONG)
print(os.environ["HOME"])
# => /home/user/.hermes/profiles/worker/home  (isolated, by design)
# No way to find the real user home!

After

# In execute_code subprocess:
import os
from pathlib import Path
print(os.environ["HOME"])
# => /home/user/.hermes/profiles/worker/home  (isolated, by design)
print(os.environ.get("HERMES_REAL_HOME", os.environ["HOME"]))
# => /home/user  (the real user home)

Changes

  1. New get_real_home() helper in hermes_constants.py — resolves the actual user home independently of profile isolation:

    • Priority: HERMES_REAL_HOME env → HOME env → expanduser("~")/tmp
  2. 4 subprocess spawners now inject HERMES_REAL_HOME alongside the profile HOME:

    • tools/code_execution_tool.py (execute_code)
    • tools/environments/local.py (terminal background + run_env)
    • agent/copilot_acp_client.py (Copilot ACP)

Usage pattern for skill helpers

import os
from pathlib import Path

# Find the real .hermes/ regardless of profile isolation
_real_home = Path(os.environ.get("HERMES_REAL_HOME", os.environ.get("HOME", str(Path.home()))))
HERMES_BASE = _real_home / ".hermes"

Testing

  • 8 new tests:
    • 4 unit tests for get_real_home() (HOME env, HERMES_REAL_HOME priority, expanduser fallback, /tmp fallback)
    • 3 subprocess env tests (execute_code, local env, no isolation case)
    • 1 integration test (subprocess finds .hermes/ via HERMES_REAL_HOME)
  • 150 existing subprocess/code_execution tests passing (0 regressions)

Files changed

FileChange
hermes_constants.pyAdd get_real_home() helper + update docstring
tools/code_execution_tool.pyInject HERMES_REAL_HOME in child_env
tools/environments/local.pyInject HERMES_REAL_HOME (2 locations)
agent/copilot_acp_client.pyInject HERMES_REAL_HOME in subprocess env
tests/test_subprocess_real_home.pyNew: 8 tests

Closes #25114

Changed files

  • agent/copilot_acp_client.py (modified, +8/-1)
  • hermes_constants.py (modified, +34/-0)
  • tests/test_subprocess_real_home.py (added, +143/-0)
  • tools/code_execution_tool.py (modified, +2/-0)
  • tools/environments/local.py (modified, +4/-0)

Code Example

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

---

_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"
RAW_BUFFERClick to expand / collapse

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix Bug: HOME env corrupted inside Hermes profile runtime context — Path.home() resolves to wrong directory [1 pull requests, 1 participants]