{"record":{"id":"300276e8edb0d4df","repo":"LGUG2Z/komorebi","slug":"there-is-no-home-directory","errorCode":null,"errorMessage":"there is no home directory","messagePattern":"there is no home directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"komorebi-bar/src/bar.rs","lineNumber":635,"sourceCode":"        };\n    }\n\n    fn try_apply_theme(&mut self, ctx: &Context) {\n        match &self.config.theme {\n            Some(theme) => {\n                apply_theme(\n                    ctx,\n                    theme.clone(),\n                    self.bg_color.clone(),\n                    self.bg_color_with_alpha.clone(),\n                    self.config.transparency_alpha,\n                    self.config.grouping,\n                    self.render_config.clone(),\n                );\n            }\n            None => {\n                let home_dir: PathBuf = std::env::var(\"KOMOREBI_CONFIG_HOME\").map_or_else(\n                    |_| dirs::home_dir().expect(\"there is no home directory\"),\n                    |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                        home\n\n                    },\n                );\n\n                let bar_transparency_alpha = self.config.transparency_alpha;\n                let bar_grouping = self.config.grouping;\n                let config = home_dir.join(\"komorebi.json\");\n                match komorebi_client::StaticConfig::read(&config) {\n                    Ok(config) => {","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi-bar/src/bar.rs#L617-L653","documentation":"While applying the bar theme in `try_apply_theme` (called from `apply_config` and `update`), komorebi-bar resolves its config home directory: it reads `KOMOREBI_CONFIG_HOME`, and if unset falls back to `dirs::home_dir()`. The expect `\"there is no home directory\"` panics when the fallback also fails, i.e. the OS gives no home directory for the current user.","triggerScenarios":"Running komorebi-bar with `KOMOREBI_CONFIG_HOME` unset AND `dirs::home_dir()` returning None — typically when the `USERPROFILE`/`HOME` environment variables are missing in the process environment (stripped env in services, scheduled tasks, or exotic launchers on Windows).","commonSituations":"Launching the bar from a service or task scheduler with a minimal environment, running inside a container or CI shell with no USERPROFILE, or corrupted user profile env vars so Windows cannot resolve a home directory.","solutions":["Set `KOMOREBI_CONFIG_HOME` to a valid directory before launching the bar (e.g. `$Env:KOMOREBI_CONFIG_HOME = \"$Env:USERPROFILE\\.config\\komorebi\"`).","Ensure `USERPROFILE` (Windows) or `HOME` (Unix) is set and points to an existing directory in the environment that starts the bar.","Launch the bar from a normal user shell rather than a stripped service context, or pass the env vars explicitly to the process.","Library-side: handle `dirs::home_dir()` returning None with an error message instead of an expect panic."],"exampleFix":"// before\nlet home_dir: PathBuf = std::env::var(\"KOMOREBI_CONFIG_HOME\").map_or_else(\n    |_| dirs::home_dir().expect(\"there is no home directory\"),\n    |home_path| { /* ... */ },\n);\n// after\nlet home_dir: PathBuf = std::env::var(\"KOMOREBI_CONFIG_HOME\").map_or_else(\n    |_| dirs::home_dir().ok_or_else(|| anyhow!(\"there is no home directory; set KOMOREBI_CONFIG_HOME\"))?,\n    |home_path| { /* ... */ },\n);","handlingStrategy":"try-catch","validationCode":"// check before starting the bar (PowerShell)\nif (-not $Env:KOMOREBI_CONFIG_HOME -and -not $Env:USERPROFILE) {\n    throw \"Neither KOMOREBI_CONFIG_HOME nor USERPROFILE is set; the bar cannot resolve a config home\"\n}","typeGuard":"fn resolve_home_dir() -> Option<PathBuf> {\n    std::env::var_os(\"KOMOREBI_CONFIG_HOME\")\n        .map(PathBuf::from)\n        .or_else(|| dirs::home_dir())\n}","tryCatchPattern":"// PowerShell wrapper that guarantees a home before launching\nif (-not $Env:KOMOREBI_CONFIG_HOME) {\n    $Env:KOMOREBI_CONFIG_HOME = \"$Env:USERPROFILE\\.config\\komorebi\"\n}\n& komorebi-bar","preventionTips":["Always set KOMOREBI_CONFIG_HOME explicitly in your shell profile before launching the bar.","Never launch the bar from stripped-environment contexts (services, schedulers) without exporting USERPROFILE/HOME.","Sanity-check with `echo $Env:USERPROFILE` in the exact session used to start komorebi.","Wrap the bar launch in a script that validates env vars first."],"tags":["rust","panic","environment","home-directory","config"],"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"}