{"record":{"id":"3de6b902faad1033","repo":"Universal-Debloater-Alliance/universal-android-debloater-next-generation","slug":"can-t-detect-config-dir","errorCode":null,"errorMessage":"Can't detect config dir","messagePattern":"Can't detect config dir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/uad-core/src/lib.rs","lineNumber":21,"sourceCode":"    clippy::missing_errors_doc,\n    clippy::collapsible_if,\n    clippy::uninlined_format_args,\n    clippy::result_unit_err,\n    reason = \"Doc+style pedantic lints are out-of-scope for this pass\"\n)]\n\npub mod adb;\npub mod config;\npub mod save;\npub mod sync;\npub mod uad_lists;\npub mod update;\npub mod utils;\n\nuse std::path::PathBuf;\nuse std::sync::LazyLock;\npub static CONFIG_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| utils::setup_uad_dir(&dirs::config_dir().expect(\"Can't detect config dir\")));\npub static CACHE_DIR: LazyLock<PathBuf> =\n    LazyLock::new(|| utils::setup_uad_dir(&dirs::cache_dir().expect(\"Can't detect cache dir\")));\n","sourceCodeStart":3,"sourceCodeEnd":24,"githubUrl":"https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/blob/64465c850c7ed36329e67165ac08501abffb218e/crates/uad-core/src/lib.rs#L3-L24","documentation":"CONFIG_DIR is a LazyLock that calls dirs::config_dir(); if the OS config directory cannot be determined (None), expect panics with \"Can't detect config dir\". This happens at first access of CONFIG_DIR, typically during app startup.","triggerScenarios":"First read of uad_core::CONFIG_DIR when dirs::config_dir() returns None — on Linux/Windows this means XDG_CONFIG_HOME unset or empty and $HOME unset or empty (or similar on other platforms).","commonSituations":"Running under systemd units, cron, Docker, or CI without HOME set; running as a system user with no home directory; stripped environment variables.","solutions":["Set HOME to an existing writable directory (Linux/macOS) before launching.","Set XDG_CONFIG_HOME explicitly to a writable path.","If running as a service user, give it a home dir (usermod -m) or run with Environment=HOME=...","Check in code: std::env::var(\"HOME\")/dirs::config_dir() before initializing, and fail with a clear message."],"exampleFix":"// before\nlet dir = dirs::config_dir().expect(\"Can't detect config dir\");\n// after\nlet dir = dirs::config_dir().unwrap_or_else(|| {\n    std::env::var(\"HOME\").map(PathBuf::from).unwrap_or_else(|_| PathBuf::from(\"/tmp\"))\n});","handlingStrategy":"validation","validationCode":"let ok = std::env::var(\"XDG_CONFIG_HOME\").map(|v| !v.is_empty()).unwrap_or(false)\n    || std::env::var(\"HOME\").map(|v| !v.is_empty()).unwrap_or(false);\nif !ok { return Err(\"cannot determine config dir: set HOME or XDG_CONFIG_HOME\"); }","typeGuard":"fn config_dir_available() -> bool { dirs::config_dir().is_some() }","tryCatchPattern":"let dir = std::panic::catch_unwind(|| uad_core::CONFIG_DIR.clone())\n    .unwrap_or_else(|_| { eprintln!(\"no config dir: set HOME or XDG_CONFIG_HOME\"); std::process::exit(1); });","preventionTips":["Always launch with HOME set (systemd: Environment=HOME=%h).","Set XDG_CONFIG_HOME explicitly in containers and CI.","Give service accounts a home directory.","Probe dirs::config_dir() in the launcher before initializing the app."],"tags":["environment","config","panic","rust","dirs"],"backgroundTag":"missing-env-var","analyzedSha":"64465c850c7ed36329e67165ac08501abffb218e","analyzedAt":"2026-09-12T09:09:23.137Z","contentChangedAt":"2026-09-12T09:09:23.137Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}