{"record":{"id":"6a057401d1b8187c","repo":"sinelaw/fresh","slug":"could-not-determine-config-directory","errorCode":null,"errorMessage":"Could not determine config directory","messagePattern":"Could not determine config directory","errorType":"exception","errorClass":"io::Error (NotFound)","httpStatus":null,"severity":"critical","filePath":"crates/fresh-editor-core/src/config_io.rs","lineNumber":1066,"sourceCode":"    /// User's downloads directory (for file open dialog shortcuts)\n    pub downloads_dir: Option<std::path::PathBuf>,\n}\n\nimpl DirectoryContext {\n    /// Create a DirectoryContext from the system directories\n    /// This should ONLY be called from main()\n    pub fn from_system() -> std::io::Result<Self> {\n        let data_dir = dirs::data_dir()\n            .ok_or_else(|| {\n                std::io::Error::new(\n                    std::io::ErrorKind::NotFound,\n                    \"Could not determine data directory\",\n                )\n            })?\n            .join(\"fresh\");\n\n        let config_dir = Self::default_config_dir().ok_or_else(|| {\n            std::io::Error::new(\n                std::io::ErrorKind::NotFound,\n                \"Could not determine config directory\",\n            )\n        })?;\n\n        Ok(Self {\n            data_dir,\n            config_dir,\n            home_dir: dirs::home_dir(),\n            documents_dir: dirs::document_dir(),\n            downloads_dir: dirs::download_dir(),\n        })\n    }\n\n    /// Create a DirectoryContext for testing with a temp directory\n    /// All paths point to subdirectories within the provided temp_dir\n    pub fn for_testing(temp_dir: &std::path::Path) -> Self {\n        Self {","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor-core/src/config_io.rs#L1048-L1084","documentation":"DirectoryContext::from_system fails when it cannot determine the user config directory (dirs::config_dir() returns None, e.g. XDG_CONFIG_HOME unset and no home directory resolvable). It is thrown after the data-directory check, so the environment lacks both XDG style directories. Like the data-dir error, it is an environment problem.","triggerScenarios":"Calling DirectoryContext::from_system() when DirectoryContext::default_config_dir() (backed by dirs::config_dir()) returns None — no XDG_CONFIG_HOME and no resolvable home.","commonSituations":"Headless services, containers, or cron jobs with an empty environment; broken user accounts without a home directory.","solutions":["Set XDG_CONFIG_HOME (or $HOME) in the environment before launch.","For systemd services add Environment=HOME=/home/user or EnvFile=/etc/default/app.","Verify the user's home directory exists and is resolvable."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if std::env::var(\"XDG_CONFIG_HOME\").is_err() && std::env::var(\"HOME\").is_err() {\n    eprintln!(\"HOME/XDG_CONFIG_HOME unset; config directory cannot be resolved\");\n}","typeGuard":null,"tryCatchPattern":"let ctx = DirectoryContext::from_system().or_else(|_| {\n    std::env::set_var(\"XDG_CONFIG_HOME\", \"/tmp/fresh-config\");\n    DirectoryContext::from_system()\n})?;","preventionTips":["Ensure XDG_CONFIG_HOME or HOME is present in launch environments","Use EnvFile in systemd units","Smoke-test the binary in a bare-env container"],"tags":["environment","directories","io"],"backgroundTag":"missing-env-var","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}