{"record":{"id":"e8bfd528a2ca9e5d","repo":"LGUG2Z/komorebi","slug":"could-not-find-home-dir","errorCode":null,"errorMessage":"could not find home dir","messagePattern":"could not find home dir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"komorebic/src/main.rs","lineNumber":1883,"sourceCode":"            println!(\"in order for the autostart command to work properly\");\n        }\n        SubCommand::DisableAutostart => {\n            let startup_dir = startup_dir()?;\n            let shortcut_file = startup_dir.join(\"komorebi.lnk\");\n\n            if shortcut_file.is_file() {\n                std::fs::remove_file(shortcut_file)?;\n            }\n        }\n        SubCommand::Check(args) => {\n            let home_display = HOME_DIR.display();\n            if HAS_CUSTOM_CONFIG_HOME.load(Ordering::SeqCst) {\n                println!(\"KOMOREBI_CONFIG_HOME detected: {home_display}\\n\");\n            } else {\n                println!(\n                    \"No KOMOREBI_CONFIG_HOME detected, defaulting to {}\\n\",\n                    dirs::home_dir()\n                        .expect(\"could not find home dir\")\n                        .to_string_lossy()\n                );\n            }\n\n            println!(\"Looking for configuration files in {home_display}\\n\");\n\n            let static_config = if let Some(static_config) = args.komorebi_config {\n                println!(\n                    \"Using an arbitrary configuration file passed to --komorebi-config flag\\n\"\n                );\n                static_config\n            } else {\n                HOME_DIR.join(\"komorebi.json\")\n            };\n\n            let config_pwsh = HOME_DIR.join(\"komorebi.ps1\");\n            let config_ahk = HOME_DIR.join(\"komorebi.ahk\");\n            let config_whkd = WHKD_CONFIG_DIR.join(\"whkdrc\");","sourceCodeStart":1865,"sourceCodeEnd":1901,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebic/src/main.rs#L1865-L1901","documentation":"When printing status/configuration diagnostics, komorebic falls back to dirs::home_dir() to display the default config location when no KOMOREBI_CONFIG_HOME is set. It panics with 'could not find home dir' when the OS home directory cannot be resolved in that fallback path.","triggerScenarios":"Running a komorebic command that prints config diagnostics while HAS_CUSTOM_CONFIG_HOME is false (no valid KOMOREBI_CONFIG_HOME) and dirs::home_dir() returns None.","commonSituations":"Running status/quickstart-like output commands from a service account or environment without USERPROFILE/HOME; containerized runs with an empty environment.","solutions":["Set KOMOREBI_CONFIG_HOME so the fallback to home_dir() is never taken","Set USERPROFILE/HOME in the launching environment","Run komorebic from a regular user shell","Restore the missing home directory in the profile"],"exampleFix":"// before: diagnostics panic without home\nkomorebic quickstart\n// after\nexport KOMOREBI_CONFIG_HOME=\"$HOME/.config/komorebi\"\nkomorebic quickstart","handlingStrategy":"validation","validationCode":"# Ensure a home or explicit config home before komorebic diagnostics\nif [ -z \"$HOME\" ] && [ -z \"$USERPROFILE\" ] && [ -z \"$KOMOREBI_CONFIG_HOME\" ]; then\n  echo 'Set HOME or KOMOREBI_CONFIG_HOME'; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set KOMOREBI_CONFIG_HOME so diagnostic output never needs home_dir()","Launch komorebic with a populated environment (HOME/USERPROFILE)","Avoid env -i or service contexts without a user profile","Confirm the home directory exists on disk before running komorebic commands"],"tags":["rust","environment","config","panic"],"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"}