fix(cli): respect HERMES_HOME in all remaining hardcoded ~/.hermes paths - #897
Closed
0xIbra wants to merge 6 commits into
Closed
fix(cli): respect HERMES_HOME in all remaining hardcoded ~/.hermes paths#8970xIbra wants to merge 6 commits into
0xIbra wants to merge 6 commits into
Conversation
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
Contributor
Author
|
Suggestion for preventing regressions: Once this is merged, there's nothing stopping a future contributor from introducing new hardcoded # 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 1This would be a lightweight addition to CI that ensures |
3 tasks
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all remaining files that resolve paths via
Path.home() / ".hermes"oros.path.expanduser("~/.hermes/..."), bypassing theHERMES_HOMEenvironment variable. This broke isolation when running multiple Hermes instances with distinctHERMES_HOMEdirectories (separate auth, memories, skills, cron, etc.).All hardcoded paths are replaced with calls to
get_hermes_home()fromhermes_cli.config, consistent with the pattern established in #51 and #538.Closes #892
Files changed (21 source + 2 tests)
tools/process_registry.py— processes.jsongateway/pairing.py— pairing/gateway/sticker_cache.py— sticker_cache.jsongateway/channel_directory.py— channel_directory.json, sessions.jsongateway/config.py— gateway.json, config.yaml, sessions_dir defaultgateway/mirror.py— sessions/gateway/hooks.py— hooks/gateway/platforms/base.py— image_cache/, audio_cache/, document_cache/gateway/platforms/whatsapp.py— whatsapp/sessiongateway/delivery.py— cron/outputagent/auxiliary_client.py— auth.jsonagent/prompt_builder.py— SOUL.mdcli.py— config.yaml, images/, pastes/, historyrun_agent.py— logs/tools/environments/base.py— sandboxes/tools/environments/modal.py— modal_snapshots.jsontools/environments/singularity.py— singularity_snapshots.jsontools/tts_tool.py— audio_cachehermes_cli/status.py— cron/jobs.json, sessions.jsonhermes_cli/gateway.py— logs/, whatsapp sessionhermes_cli/main.py— whatsapp/sessiontests/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_HOMEImportant
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
HERMES_HOME=/tmp/test-hermes hermes doctorto verify override works end-to-endHERMES_HOMEvalues and confirm full isolation (auth, memories, skills, sessions, cron)