{"record":{"id":"d102c94aab80d261","repo":"tinyhumansai/openhuman","slug":"failed-to-load-dotenv-from-openhuman-dotenv-path","errorCode":null,"errorMessage":"failed to load dotenv from OPENHUMAN_DOTENV_PATH={path}: {e}","messagePattern":"failed to load dotenv from OPENHUMAN_DOTENV_PATH=(.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/cli.rs","lineNumber":341,"sourceCode":"        \"sentry-test unavailable: built without the crash-reporting feature — \\\n         rebuild with `--features crash-reporting`\"\n    ))\n}\n\n/// Loads key/value pairs from a `.env` file into the process environment.\n///\n/// This is used for all CLI entrypoints so direct namespace commands pick up\n/// the same repo-local configuration as `run` / `serve`.\n///\n/// Precedence:\n/// 1. Variables already set in the process environment are **not** overwritten.\n/// 2. If `OPENHUMAN_DOTENV_PATH` is set, that file is loaded.\n/// 3. Otherwise, it searches for `.env` in the current working directory.\npub(crate) fn load_dotenv_for_cli() -> Result<()> {\n    match std::env::var(\"OPENHUMAN_DOTENV_PATH\") {\n        Ok(path) if !path.trim().is_empty() => {\n            dotenvy::from_path(&path).map_err(|e| {\n                anyhow::anyhow!(\"failed to load dotenv from OPENHUMAN_DOTENV_PATH={path}: {e}\")\n            })?;\n        }\n        _ => {\n            let _ = dotenvy::dotenv();\n        }\n    }\n    Ok(())\n}\n\n/// Handles the `run` subcommand to start the core HTTP/JSON-RPC server.\n///\n/// This command boots the main application server, including its JSON-RPC\n/// endpoint, Socket.IO bridge, and background services (voice, vision, etc.).\n///\n/// # Arguments\n///\n/// * `args` - Command-line arguments for the `run` command (e.g., `--port`).\nfn run_server_command(args: &[String]) -> Result<()> {","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/src/core/cli.rs#L323-L359","documentation":"OPENHUMAN_DOTENV_PATH is set to a non-empty value, and dotenvy::from_path failed on it — the file does not exist, is unreadable, or is malformed. This path is strict by design: an explicitly configured dotenv that silently fails would hide config differences. By contrast, when the variable is unset, the cwd `.env` discovery (`dotenvy::dotenv()`) ignores errors entirely.","triggerScenarios":"OPENHUMAN_DOTENV_PATH points to a nonexistent or misspelled file; the file lacks read permission; the .env has dotenv syntax errors; the path is relative and the process cwd differs from the assumed one.","commonSituations":"A stale variable exported in a shell profile or CI job pointing at a moved/removed file; container mounts that place .env elsewhere; deploying with a different user that cannot read the file.","solutions":["Verify the target: `ls -l \"$OPENHUMAN_DOTENV_PATH\"` and confirm it exists and is readable","Point the variable at the correct file, preferably with an absolute path","If cwd `.env` discovery is what you want, unset the variable: `unset OPENHUMAN_DOTENV_PATH`"],"exampleFix":"# before\nexport OPENHUMAN_DOTENV_PATH=.env.local   # file does not exist\nopenhuman run\n# after\nexport OPENHUMAN_DOTENV_PATH=/abs/path/to/repo/.env.local\nopenhuman run\n# or fall back to cwd discovery\nunset OPENHUMAN_DOTENV_PATH","handlingStrategy":"validation","validationCode":"# bash: check the explicit dotenv target before any openhuman command\nif [ -n \"${OPENHUMAN_DOTENV_PATH:-}\" ] && [ ! -r \"$OPENHUMAN_DOTENV_PATH\" ]; then\n  echo \"OPENHUMAN_DOTENV_PATH is not a readable file: $OPENHUMAN_DOTENV_PATH\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for OPENHUMAN_DOTENV_PATH — relative paths resolve against whatever cwd the CLI starts in","Unset the variable in environments that should rely on cwd `.env` discovery (which is non-fatal)","Remember precedence: already-set process env vars win, so a broken file may still 'work' silently if vars are exported elsewhere"],"tags":["dotenv","configuration","environment","cli"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}