mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: resolve .env and config paths from HERMES_HOME, not PROJECT_ROOT
The `hermes` CLI entry point (hermes_cli/main.py) and the agent runner (run_agent.py) only loaded .env from the project installation directory. After the standard installer, code lives at ~/.hermes/hermes-agent/ but config lives at ~/.hermes/ — so the .env was never found. Aligns these entry points with the pattern already used by gateway/run.py and rl_cli.py: load ~/.hermes/.env first, fall back to project root .env for dev-mode compatibility. Also fixes: - status.py checking .env existence and API keys at PROJECT_ROOT - doctor.py KeyError on tool availability (missing_vars vs env_vars) - doctor.py checking logs/ and Skills Hub at PROJECT_ROOT instead of HERMES_HOME - doctor.py redundant logs/ check (already covered by subdirectory loop) - mini-swe-agent loading config from platformdirs default instead of ~/.hermes/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e5bd25c73f
commit
5a569eb1b6
4 changed files with 46 additions and 33 deletions
|
|
@ -33,14 +33,20 @@ from pathlib import Path
|
|||
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
# Load .env file
|
||||
# Load .env from ~/.hermes/.env first, then project root as dev fallback
|
||||
from dotenv import load_dotenv
|
||||
env_path = PROJECT_ROOT / '.env'
|
||||
if env_path.exists():
|
||||
from hermes_cli.config import get_env_path, get_hermes_home
|
||||
_user_env = get_env_path()
|
||||
if _user_env.exists():
|
||||
try:
|
||||
load_dotenv(dotenv_path=env_path, encoding="utf-8")
|
||||
load_dotenv(dotenv_path=_user_env, encoding="utf-8")
|
||||
except UnicodeDecodeError:
|
||||
load_dotenv(dotenv_path=env_path, encoding="latin-1")
|
||||
load_dotenv(dotenv_path=_user_env, encoding="latin-1")
|
||||
load_dotenv(dotenv_path=PROJECT_ROOT / '.env', override=False)
|
||||
|
||||
# Point mini-swe-agent at ~/.hermes/ so it shares our config
|
||||
os.environ.setdefault("MSWEA_GLOBAL_CONFIG_DIR", str(get_hermes_home()))
|
||||
os.environ.setdefault("MSWEA_SILENT_STARTUP", "1")
|
||||
|
||||
import logging
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue