{"record":{"id":"b9ea7216cae2c64d","repo":"Hmbown/CodeWhale","slug":"could-not-resolve-home-directory-for-filekeyringst","errorCode":null,"errorMessage":"could not resolve home directory for FileKeyringStore","messagePattern":"could not resolve home directory for FileKeyringStore","errorType":"exception","errorClass":"SecretsError::Io","httpStatus":null,"severity":"error","filePath":"crates/secrets/src/lib.rs","lineNumber":841,"sourceCode":"fn default_codewhale_secrets_path() -> Result<PathBuf, SecretsError> {\n    Ok(codewhale_paths::codewhale_home()\n        .map_err(|error| {\n            SecretsError::Io(std::io::Error::new(std::io::ErrorKind::InvalidInput, error))\n        })?\n        .ok_or_else(home_resolution_error)?\n        .join(\"secrets\")\n        .join(\"secrets.json\"))\n}\n\nfn legacy_deepseek_secrets_path() -> Result<PathBuf, SecretsError> {\n    Ok(codewhale_paths::legacy_deepseek_home()\n        .ok_or_else(home_resolution_error)?\n        .join(\"secrets\")\n        .join(\"secrets.json\"))\n}\n\nfn home_resolution_error() -> SecretsError {\n    SecretsError::Io(std::io::Error::new(\n        std::io::ErrorKind::NotFound,\n        \"could not resolve home directory for FileKeyringStore\",\n    ))\n}\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq)]\nenum SecretBackendSelection {\n    File,\n    System,\n    Unknown,\n}\n\n/// Secret-store backend selected by configuration for a structural diagnostic.\n///\n/// This type deliberately describes only configuration and filesystem shape.\n/// It never implies that a provider credential exists.\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]\n#[serde(rename_all = \"snake_case\")]","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/secrets/src/lib.rs#L823-L859","documentation":"FileKeyringStore cannot determine the user's home directory, so it cannot locate its secrets.json backing file. The secrets crate requires a home directory to derive the on-disk keyring store path (`$HOME/secrets/secrets.json`), and throws this NotFound io::Error wrapped in SecretsError when `dirs::home_dir()` (or equivalent) returns None.","triggerScenarios":"Constructing or using FileKeyringStore when the home directory cannot be resolved: `HOME` unset, `dirs::home_dir()` returning None, or running under a service account / sandboxed process with no home configured.","commonSituations":"Running the binary under systemd with no `$HOME`, inside Docker containers without `HOME` set, CI runners with stripped environments, or setuid/nonstandard users lacking a passwd entry.","solutions":["Set the HOME environment variable to a writable directory the user owns (e.g. `export HOME=/home/user` or `Environment=HOME=/var/lib/service` in systemd).","Ensure the user has a valid passwd entry with a home path (check `getent passwd $(whoami)`).","In containers, create the home directory and pass it via `-e HOME=/home/app` and a mounted/created volume.","If programmatic, use the store API that accepts an explicit root/path instead of relying on home resolution."],"exampleFix":"// before (Dockerfile)\nCMD [\"codewhale\"]\n\n// after\nENV HOME=/home/app\nRUN mkdir -p /home/app/secrets && chown -R app:app /home/app\nCMD [\"codewhale\"]","handlingStrategy":"validation","validationCode":"fn home_is_resolvable() -> bool {\n    std::env::var_os(\"HOME\").map(|h| !h.is_empty()).unwrap_or(false)\n}\nif !home_is_resolvable() {\n    eprintln!(\"HOME is not set; FileKeyringStore will fail\");\n}","typeGuard":"fn has_home() -> Option<String> {\n    std::env::var(\"HOME\").ok().filter(|h| !h.is_empty())\n}","tryCatchPattern":"match store.init() {\n    Err(SecretsError::Io(e)) if e.kind() == std::io::ErrorKind::NotFound => {\n        // home unresolvable: fall back to env-provided key or prompt user\n    }\n    other => other?,\n}","preventionTips":["Always export HOME in service units, containers, and cron environments.","Smoke-test home resolution at process startup before touching secrets.","Run under a user account with a valid passwd home entry."],"tags":["filesystem","environment","secrets","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}