Skip to content

fix: sandbox HOME override breaks Path.home() and expanduser() resolution #8669

@iRonin

Description

@iRonin

Problem

The terminal sandbox environment overrides HOME to {HERMES_HOME}/home/ for profile isolation. While this is intentional for subprocess credential isolation (git, gh, npm, etc.), it silently breaks all code that uses Path.home(), os.path.expanduser(), or os.environ.get("HERMES_HOME", Path.home() / ".hermes").

Impact

Category Files What breaks
Native root detection hermes_constants.py:36, cli.py:3791, profiles.py:152 Path.home() / ".hermes" resolves to profile home instead of real ~/.hermes
External tool configs agent/anthropic_adapter.py:311,333,459, tools/tool_backend_helpers.py:44, gateway/status.py:48 Looks for ~/.claude/, ~/.modal.toml, ~/.local/state/ in profile home
User file paths tools/file_tools.py:82,102, tools/delegate_tool.py:142, cli.py:1088,1158 ~/myfile expands to profile home instead of real home
Wrapper scripts profiles.py:152 ~/.local/bin resolves to profile home

Root cause

The sandbox sets HOME to the profile's home/ directory. The codebase uses Path.home() (which reads from the process's HOME env var) as a fallback when HERMES_HOME isn't set, and for native path resolution.

Proposed fix

  1. Capture the real user home at import time (before sandbox overrides HOME) in hermes_constants.py
  2. Replace all Path.home() calls that need the real user home with a new get_real_home() helper
  3. Keep Path.home() for expanduser() in file tools (or use the real home for those too)

Files to update:

File Change
hermes_constants.py Add _REAL_HOME and get_real_home()
hermes_constants.py:36 Use get_real_home() in get_default_hermes_root()
cli.py:3791 Use get_real_home() for profile parent detection
profiles.py:152 Use get_real_home() for wrapper dir
agent/anthropic_adapter.py Use get_real_home() for Claude config paths
tools/tool_backend_helpers.py Use get_real_home() for modal.toml
gateway/status.py:48 Use get_real_home() for XDG state fallback
tools/file_tools.py Use get_real_home() for expanduser
tools/delegate_tool.py Use get_real_home() for script paths

Why this matters

  • gh CLI auth fails because it looks in profile home for keychain tokens
  • Claude adapter can't find real Claude credentials
  • User's ~/Documents/myfile.txt resolves to the wrong place
  • hermes profile list may fail to find the profiles root

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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