{"record":{"id":"e4cfa7649711bbef","repo":"Hmbown/CodeWhale","slug":"failed-to-resolve-settings-path-no-config-directo","errorCode":null,"errorMessage":"Failed to resolve settings path: no config directory found.","messagePattern":"Failed to resolve settings path: no config directory found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":747,"sourceCode":"/// `/config preset` command so the bundle is never defined twice.\n#[must_use]\npub fn preset_fields(name: &str) -> Option<&'static [(&'static str, &'static str)]> {\n    match name.trim().to_ascii_lowercase().as_str() {\n        \"calm\" => Some(CALM_PRESET_FIELDS),\n        _ => None,\n    }\n}\n\nimpl Settings {\n    /// Get the canonical settings file path.\n    ///\n    /// New writes should target `~/.codewhale/settings.toml`. Legacy\n    /// DeepSeek-branded paths remain readable as fallbacks during load, but we\n    /// no longer surface them as the primary path in `/config`.\n    pub fn path() -> Result<PathBuf> {\n        let (primary, _legacy_home, legacy_config_dir) = settings_path_candidates();\n        primary.or(legacy_config_dir).ok_or_else(|| {\n            anyhow::anyhow!(\"Failed to resolve settings path: no config directory found.\")\n        })\n    }\n\n    /// Load settings from disk, or return defaults if not found\n    pub fn load() -> Result<Self> {\n        let mut settings = Self::load_persisted()?;\n        settings.apply_env_overrides();\n        Ok(settings)\n    }\n\n    /// Load settings for a diagnostic without migrating a legacy file.\n    ///\n    /// This preserves the same candidate precedence, parser normalization, and\n    /// environment overlays as [`Settings::load`]. Unlike an interactive\n    /// startup, diagnostics must not create `~/.codewhale/settings.toml` just\n    /// because they inspected a legacy `~/.deepseek/settings.toml` file.\n    pub(crate) fn load_read_only() -> Result<Self> {\n        let mut settings = Self::load_persisted_read_only()?;","sourceCodeStart":729,"sourceCodeEnd":765,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/settings.rs#L729-L765","documentation":"`Settings::path()` resolves where settings.toml should live by taking the first available candidate among the primary (~/.codewhale/settings.toml style) home-based path and the legacy config directory. If neither the home directory nor any config directory can be determined (e.g. no HOME/XDG_CONFIG_HOME and no resolvable profile directory), there is nowhere to read or write settings and this error is returned.","triggerScenarios":"Calling Settings::path() (public) in an environment where the user's home directory and the system config directory are both unresolvable: HOME unset, XDG_CONFIG_HOME unset, no passwd entry, or a service/CI context without a user profile.","commonSituations":"Running the TUI in a bare Docker container or systemd service with no HOME set; CI jobs with a stripped environment; cron jobs missing env; running as a user without a home directory.","solutions":["Set the HOME environment variable (or USERPROFILE on Windows) to a writable directory before launching","Set XDG_CONFIG_HOME to an existing writable directory so the primary candidate resolves","Run the process as a real user account that has a home directory, or pre-create the home dir"],"exampleFix":"// before: spawned without HOME\nlet path = Settings::path()?; // Err: no config directory found\n// after: ensure env before launch\nstd::env::set_var(\"HOME\", \"/home/deploy\");\nstd::fs::create_dir_all(\"/home/deploy/.codewhale\")?;\nlet path = Settings::path()?;","handlingStrategy":"fallback","validationCode":"let has_home = std::env::var_os(\"HOME\").or_else(|| std::env::var_os(\"USERPROFILE\")).is_some()\n    || std::env::var_os(\"XDG_CONFIG_HOME\").is_some();\nif !has_home { eprintln!(\"no config directory resolvable\"); }","typeGuard":null,"tryCatchPattern":"match Settings::path() {\n    Ok(p) => p,\n    Err(e) => { eprintln!(\"set HOME or XDG_CONFIG_HOME: {e}\"); std::process::exit(2); }\n}","preventionTips":["Set HOME/USERPROFILE in containers, CI, and service units","Set XDG_CONFIG_HOME for non-interactive runs","Pre-create the config directory before first launch"],"tags":["config","environment","path-resolution"],"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"}