{"record":{"id":"8ea3eba0abbbad65","repo":"LGUG2Z/komorebi","slug":"there-is-no-home-directory-8ea3eb","errorCode":null,"errorMessage":"there is no home directory","messagePattern":"there is no home directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"komorebi/src/lib.rs","lineNumber":201,"sourceCode":"            kind: ApplicationIdentifier::Exe,\n            id: String::from(\"firefox.exe\"),\n            matching_strategy: Option::from(MatchingStrategy::Equals),\n        }),\n    ]));\n    static ref DUPLICATE_MONITOR_SERIAL_IDS: Arc<RwLock<Vec<String>>> =\n        Arc::new(RwLock::new(Vec::new()));\n    static ref SUBSCRIPTION_PIPES: Arc<Mutex<HashMap<String, File>>> =\n        Arc::new(Mutex::new(HashMap::new()));\n    pub static ref SUBSCRIPTION_SOCKETS: Arc<Mutex<HashMap<String, PathBuf>>> =\n        Arc::new(Mutex::new(HashMap::new()));\n    pub static ref SUBSCRIPTION_SOCKET_OPTIONS: Arc<Mutex<HashMap<String, SubscribeOptions>>> =\n        Arc::new(Mutex::new(HashMap::new()));\n    static ref TCP_CONNECTIONS: Arc<Mutex<HashMap<String, TcpStream>>> =\n        Arc::new(Mutex::new(HashMap::new()));\n    static ref HIDING_BEHAVIOUR: Arc<Mutex<HidingBehaviour>> =\n        Arc::new(Mutex::new(HidingBehaviour::Cloak));\n    pub static ref HOME_DIR: PathBuf = {\n        std::env::var(\"KOMOREBI_CONFIG_HOME\").map_or_else(|_| dirs::home_dir().expect(\"there is no home directory\"), |home_path| {\n            let home = home_path.replace_env();\n\n            assert!(\n                home.is_dir(),\n                \"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory\"\n            );\n\n\n            home\n        })\n    };\n    pub static ref DATA_DIR: PathBuf = dirs::data_local_dir().expect(\"there is no local data directory\").join(\"komorebi\");\n    pub static ref AHK_EXE: String = {\n        let mut ahk: String = String::from(\"autohotkey.exe\");\n\n        if let Ok(komorebi_ahk_exe) = std::env::var(\"KOMOREBI_AHK_EXE\")\n            && which(&komorebi_ahk_exe).is_ok() {\n                ahk = komorebi_ahk_exe;","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi/src/lib.rs#L183-L219","documentation":"komorebi's global HOME_DIR is resolved once at first use: it prefers KOMOREBI_CONFIG_HOME and otherwise falls back to dirs::home_dir(), panicking with 'there is no home directory' if that returns None. HOME_DIR anchors config.json and state file locations, so without it komorebi cannot start.","triggerScenarios":"First access to the HOME_DIR lazy static while KOMOREBI_CONFIG_HOME is unset and dirs::home_dir() returns None (USERPROFILE/HOME not set or the profile directory cannot be resolved).","commonSituations":"Running komorebi from a service or SSH session with a scrubbed environment; a broken Windows user profile; launching via a wrapper script that clears environment variables; running under CI without USERPROFILE.","solutions":["Set KOMOREBI_CONFIG_HOME to an existing directory so the home-dir fallback is never used","Ensure the USERPROFILE environment variable is set and points to an existing directory before launching komorebi","Launch komorebi from a normal interactive user session, not a service/scheduler context with a stripped environment","Repair the Windows user profile if the profile directory is missing or renamed"],"exampleFix":"// before (PowerShell wrapper)\nkomorebic start -a whkd\n// after (PowerShell wrapper)\n$env:KOMOREBI_CONFIG_HOME = \"$env:USERPROFILE\\.config\"\nif (-not (Test-Path $env:KOMOREBI_CONFIG_HOME)) { throw \"config home missing\" }\nkomorebic start -a whkd","handlingStrategy":"validation","validationCode":"// PowerShell preflight before starting komorebi\nif (-not $env:KOMOREBI_CONFIG_HOME -and -not $env:USERPROFILE) {\n  throw \"Set KOMOREBI_CONFIG_HOME; no home directory is resolvable\"\n}\n","typeGuard":"// Rust\nfn resolve_home() -> Option<PathBuf> {\n    std::env::var(\"KOMOREBI_CONFIG_HOME\").ok().map(PathBuf::from)\n        .or_else(|| dirs::home_dir())\n        .filter(|p| p.is_dir())\n}","tryCatchPattern":"// Downstream code can avoid touching a bad HOME_DIR by pre-checking\nstd::env::var(\"KOMOREBI_CONFIG_HOME\")\n    .or_else(|_| std::env::var(\"USERPROFILE\"))\n    .map(PathBuf::from)\n    .filter(|p| p.is_dir())\n    .ok_or_else(|| anyhow!(\"no valid home/config directory available\"))?;","preventionTips":["Always set KOMOREBI_CONFIG_HOME in headless/service launch scripts","Verify USERPROFILE exists before spawning komorebi","Launch from interactive user sessions, not stripped environments","Check profile integrity after Windows account changes"],"tags":["windows","rust","panic","environment","home-directory"],"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-14T05:17:10.506Z"}