From 5c1ac6c70d76b6b8bdde9310c5d715fc44d424c9 Mon Sep 17 00:00:00 2001 From: aaronagent <1115117931@qq.com> Date: Thu, 9 Apr 2026 22:40:15 +0800 Subject: [PATCH] fix(config): strip `export ` prefix in .env parsers across three modules All three .env parsers use `line.partition("=")` without stripping the bash-compatible `export ` prefix first. A line like `export API_KEY=sk-...` produces key `"export API_KEY"` instead of `"API_KEY"`, silently ignoring the variable and causing auth failures for users who copy-paste from bash profiles or follow tutorials that include `export`. - tools/skills_tool.py: `load_env()` for skill environment - hermes_cli/config.py: `load_env()` for core config - hermes_cli/main.py: `_has_any_provider_configured()` inline parser Co-Authored-By: Claude Sonnet 4.6 (1M context) --- hermes_cli/config.py | 5 +++++ hermes_cli/main.py | 2 ++ tools/skills_tool.py | 2 ++ 3 files changed, 9 insertions(+) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index cf3cce9f89e8..d0ef0c3a2050 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -6494,6 +6494,11 @@ def load_env() -> Dict[str, str]: for line in lines: line = line.strip() if line and not line.startswith('#') and '=' in line: + # Strip the bash-compatible ``export `` prefix so lines like + # ``export API_KEY=...`` parse as ``API_KEY`` rather than being + # stored under the wrong key ``"export API_KEY"`` (#6659). + if line.startswith('export '): + line = line[7:] key, _, value = line.partition('=') env_vars[key.strip()] = _parse_env_value(value) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 77985234f075..26cc096d4001 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -828,6 +828,8 @@ def _has_any_provider_configured() -> bool: line = line.strip() if line.startswith("#") or "=" not in line: continue + if line.startswith("export "): + line = line[7:] key, _, val = line.partition("=") val = val.strip().strip("'\"") if key.strip() in provider_env_vars and val: diff --git a/tools/skills_tool.py b/tools/skills_tool.py index 2ba57adc54d4..09471690b45e 100644 --- a/tools/skills_tool.py +++ b/tools/skills_tool.py @@ -149,6 +149,8 @@ def load_env() -> Dict[str, str]: for line in f: line = line.strip() if line and not line.startswith("#") and "=" in line: + if line.startswith("export "): + line = line[7:] key, _, value = line.partition("=") env_vars[key.strip()] = value.strip().strip("\"'") return env_vars