fix: use real user home instead of sandbox-overridden HOME#8910
Conversation
Capture real HOME at module import time (before sandbox overrides it) and use get_real_home() for all Path.home() and expanduser() calls that need the actual OS user home. Files updated: - hermes_constants.py: Add _REAL_HOME and get_real_home() - hermes_constants.py: Use get_real_home() in get_hermes_home(), get_default_hermes_root() - cli.py: Profile parent detection uses real home - profiles.py: Wrapper dir uses real home - agent/anthropic_adapter.py: Claude config paths use real home - tools/tool_backend_helpers.py: modal.toml check uses real home - tools/file_tools.py: _expanduser() helper for real home - tools/delegate_tool.py: CWD resolution uses real home - tests/test_hermes_constants.py: Update monkeypatching for _REAL_HOME Closes NousResearch#8669
Add config setting to disable the profile HOME override.
When set to false, subprocesses keep the real OS user home
instead of being redirected to {HERMES_HOME}/home/.
Usage in config.yaml:
terminal:
profile_home_isolation: false
Files updated:
- hermes_cli/config.py: Add terminal.profile_home_isolation (default: true)
- tools/environments/local.py: Check config before overriding HOME
- tools/code_execution_tool.py: Check config before overriding HOME
Closes NousResearch#8669
…lation disabled - hermes_constants.py: Use pwd.getpwuid(os.getuid()).pw_dir to get real user home, bypassing the HOME env var entirely - tools/environments/local.py: When profile_home_isolation=false, explicitly restore real HOME in subprocess env (parent may have it already overridden) - tools/code_execution_tool.py: Same HOME restoration logic Closes NousResearch#8669
|
Thanks for the thorough write-up, but after auditing the codebase this is solving a problem that doesn't exist. The subprocess HOME override (
I verified every Also noting a bug in the PR: Closing the related issue and duplicate PRs as well. |
|
@Teknium This PR addresses a real runtime issue that code audit alone misses. The sandbox terminal environment overrides When running
The fix:
This isn't a codebase bug — it's a sandbox runtime reality. The config option gives users the choice. |
Summary
Captures the real OS user home at module import time (before the sandbox can override
HOME) and uses it for allPath.home()andos.path.expanduser()calls that need the actual user home.Problem
The terminal sandbox overrides
HOMEto{HERMES_HOME}/home/for profile isolation. This silently breaks:ghCLI auth (looks in wrong place for keychain tokens)~/Documents/file.txt)Changes
hermes_constants.py_REAL_HOMEconstant andget_real_home()helperhermes_constants.pyget_hermes_home()andget_default_hermes_root()useget_real_home()cli.pyget_real_home()hermes_cli/profiles.py_get_wrapper_dir()usesget_real_home()agent/anthropic_adapter.pyget_real_home()tools/tool_backend_helpers.pyget_real_home()tools/file_tools.py_expanduser()helper that expands~to real hometools/delegate_tool.pyget_real_home()tests/test_hermes_constants.py_REAL_HOMECloses #8669