{"record":{"id":"64027ebee381630f","repo":"LGUG2Z/komorebi","slug":"no-home-directory-found","errorCode":null,"errorMessage":"no home directory found","messagePattern":"no home directory found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"komorebi-shortcuts/src/main.rs","lineNumber":20,"sourceCode":"use std::path::PathBuf;\nuse whkd_core::Whkdrc;\n\n#[derive(Default)]\nstruct Quicklook {\n    whkdrc: Option<Whkdrc>,\n    filter: String,\n}\n\nimpl Quicklook {\n    fn new(_cc: &eframe::CreationContext<'_>) -> Self {\n        // Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.\n        // Restore app state using cc.storage (requires the \"persistence\" feature).\n        // Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use\n        // for e.g. egui::PaintCallback.\n        let mut home = std::env::var(\"WHKD_CONFIG_HOME\").map_or_else(\n            |_| {\n                dirs::home_dir()\n                    .expect(\"no home directory found\")\n                    .join(\".config\")\n            },\n            |home_path| {\n                let home = PathBuf::from(&home_path);\n\n                if home.as_path().is_dir() {\n                    home\n                } else {\n                    panic!(\n                        \"$Env:WHKD_CONFIG_HOME is set to '{home_path}', which is not a valid directory\",\n                    );\n                }\n            },\n        );\n        home.push(\"whkdrc\");\n\n        Self {\n            whkdrc: whkd_parser::load(&home).ok(),","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi-shortcuts/src/main.rs#L2-L38","documentation":"komorebi-shortcuts resolves its configuration home by first honoring WHKD_CONFIG_HOME, and falling back to dirs::home_dir().join(\".config\"). The expect panics when dirs::home_dir() returns None, i.e. the process has no discoverable home directory (HOME/USERPROFILE unset or invalid).","triggerScenarios":"Calling App::new (eframe/egui entry point) with the WHKD_CONFIG_HOME environment variable unset AND no home directory resolvable by the dirs crate (USERPROFILE/HOME missing), so dirs::home_dir() yields None and .expect panics.","commonSituations":"Running komorebi-shortcuts from a service, scheduled task, or shell with a scrubbed environment; launching from an SSH or CI context without USERPROFILE set; a corrupted user profile where the profile directory no longer exists.","solutions":["Set WHKD_CONFIG_HOME to an existing directory to bypass the home-dir lookup entirely","Ensure USERPROFILE (Windows) / HOME is set and points to an existing directory for the user running the app","Launch the app from a normal user shell rather than a service/CI context with a stripped environment","Patch the fallback to use a sensible default (e.g. the executable's directory or a temp config path) instead of panicking"],"exampleFix":"// before\ndirs::home_dir()\n    .expect(\"no home directory found\")\n    .join(\".config\")\n// after\ndirs::home_dir()\n    .map(|home| home.join(\".config\"))\n    .unwrap_or_else(|| {\n        std::env::var(\"APPDATA\")\n            .map(PathBuf::from)\n            .unwrap_or_else(|_| PathBuf::from(\".\"))\n    })","handlingStrategy":"validation","validationCode":"// PowerShell: verify resolvable config home before launching\nif (-not $env:WHKD_CONFIG_HOME) {\n  if (-not $env:USERPROFILE) { throw \"Neither WHKD_CONFIG_HOME nor USERPROFILE is set\" }\n}\n","typeGuard":"// Rust\nfn effective_config_home() -> Option<PathBuf> {\n    std::env::var(\"WHKD_CONFIG_HOME\").ok().map(PathBuf::from)\n        .or_else(|| dirs::home_dir().map(|h| h.join(\".config\")))\n}","tryCatchPattern":"match dirs::home_dir() {\n    Some(home) => configure(home.join(\".config\")),\n    None => { log::error!(\"no home directory found; skipping state restore\"); return; }\n}","preventionTips":["Set WHKD_CONFIG_HOME explicitly in shell profiles for service/CI contexts","Never launch GUI apps from environments with scrubbed env vars","Sanity-check USERPROFILE exists in launch scripts","Prefer graceful fallbacks over expect for path resolution"],"tags":["rust","panic","environment","config-path","windows"],"backgroundTag":"missing-env-var","analyzedSha":"e0709f02bfae4e503bf4640f58ee75ecbbfdbb97","analyzedAt":"2026-09-06T07:08:05.107Z","contentChangedAt":"2026-09-06T07:08:05.107Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}