Skip to content

fix(cli): respect HERMES_HOME in all remaining hardcoded ~/.hermes paths - #897

Closed
0xIbra wants to merge 6 commits into
NousResearch:mainfrom
0xIbra:fix/hermes-home-remaining-hardcoded-paths
Closed

fix(cli): respect HERMES_HOME in all remaining hardcoded ~/.hermes paths#897
0xIbra wants to merge 6 commits into
NousResearch:mainfrom
0xIbra:fix/hermes-home-remaining-hardcoded-paths

Conversation

@0xIbra

@0xIbra 0xIbra commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all remaining files that resolve paths via Path.home() / ".hermes" or os.path.expanduser("~/.hermes/..."), bypassing the HERMES_HOME environment variable. This broke isolation when running multiple Hermes instances with distinct HERMES_HOME directories (separate auth, memories, skills, cron, etc.).

All hardcoded paths are replaced with calls to get_hermes_home() from hermes_cli.config, consistent with the pattern established in #51 and #538.

Closes #892

Files changed (21 source + 2 tests)

  • tools/process_registry.py — processes.json
  • gateway/pairing.py — pairing/
  • gateway/sticker_cache.py — sticker_cache.json
  • gateway/channel_directory.py — channel_directory.json, sessions.json
  • gateway/config.py — gateway.json, config.yaml, sessions_dir default
  • gateway/mirror.py — sessions/
  • gateway/hooks.py — hooks/
  • gateway/platforms/base.py — image_cache/, audio_cache/, document_cache/
  • gateway/platforms/whatsapp.py — whatsapp/session
  • gateway/delivery.py — cron/output
  • agent/auxiliary_client.py — auth.json
  • agent/prompt_builder.py — SOUL.md
  • cli.py — config.yaml, images/, pastes/, history
  • run_agent.py — logs/
  • tools/environments/base.py — sandboxes/
  • tools/environments/modal.py — modal_snapshots.json
  • tools/environments/singularity.py — singularity_snapshots.json
  • tools/tts_tool.py — audio_cache
  • hermes_cli/status.py — cron/jobs.json, sessions.json
  • hermes_cli/gateway.py — logs/, whatsapp session
  • hermes_cli/main.py — whatsapp/session
  • tests/gateway/test_channel_directory.py — updated to use HERMES_HOME env var instead of patching Path.home()
  • tests/tools/test_clipboard.py — updated assertion to use HERMES_HOME

Important

This PR touches many files across the codebase. While each change is small and mechanical (replacing a hardcoded path with a get_hermes_home() call), the breadth warrants thorough review to ensure no import issues or edge cases were missed.

Test plan

  • Full test suite passes: 2937 passed, 2 skipped, 0 failed
  • Tested on macOS (darwin aarch64)
  • Manual test: HERMES_HOME=/tmp/test-hermes hermes doctor to verify override works end-to-end
  • Manual test: run two instances with different HERMES_HOME values and confirm full isolation (auth, memories, skills, sessions, cron)

Several files resolved paths via Path.home() / ".hermes" or
os.path.expanduser("~/.hermes/..."), bypassing the HERMES_HOME
environment variable. This broke isolation when running multiple
Hermes instances with distinct HERMES_HOME directories.

Replace all hardcoded paths with calls to get_hermes_home() from
hermes_cli.config, consistent with the rest of the codebase.

Files fixed:
- tools/process_registry.py (processes.json)
- gateway/pairing.py (pairing/)
- gateway/sticker_cache.py (sticker_cache.json)
- gateway/channel_directory.py (channel_directory.json, sessions.json)
- gateway/config.py (gateway.json, config.yaml, sessions_dir)
- gateway/mirror.py (sessions/)
- gateway/hooks.py (hooks/)
- gateway/platforms/base.py (image_cache/, audio_cache/, document_cache/)
- gateway/platforms/whatsapp.py (whatsapp/session)
- gateway/delivery.py (cron/output)
- agent/auxiliary_client.py (auth.json)
- agent/prompt_builder.py (SOUL.md)
- cli.py (config.yaml, images/, pastes/, history)
- run_agent.py (logs/)
- tools/environments/base.py (sandboxes/)
- tools/environments/modal.py (modal_snapshots.json)
- tools/environments/singularity.py (singularity_snapshots.json)
- tools/tts_tool.py (audio_cache)
- hermes_cli/status.py (cron/jobs.json, sessions.json)
- hermes_cli/gateway.py (logs/, whatsapp session)
- hermes_cli/main.py (whatsapp/session)

Tests updated to use HERMES_HOME env var instead of patching Path.home().

Closes NousResearch#892
@0xIbra

0xIbra commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

Suggestion for preventing regressions:

Once this is merged, there's nothing stopping a future contributor from introducing new hardcoded Path.home() / ".hermes" or expanduser("~/.hermes/...") paths. A simple CI grep check could catch this at PR time — something like:

# Fail if any non-test Python file introduces a hardcoded ~/.hermes path
# (excluding hermes_cli/config.py where get_hermes_home() is defined)
git diff origin/main --name-only -- '*.py' \
  | grep -v tests/ \
  | grep -v hermes_cli/config.py \
  | xargs grep -n 'Path\.home().*\.hermes\|expanduser.*\.hermes' \
  && echo "ERROR: Use get_hermes_home() from hermes_cli.config instead of hardcoding ~/.hermes paths" \
  && exit 1

This would be a lightweight addition to CI that ensures HERMES_HOME isolation doesn't regress over time.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #1233. I cherry-picked the substantive HERMES_HOME cleanup commit onto current main with your authorship preserved, then added a small follow-up for the last stale test and two remaining CLI debug-log HERMES_HOME paths. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: remaining hardcoded ~/.hermes paths bypass HERMES_HOME override

2 participants