LGUG2Z/komorebi · error
no home directory found
Error message
no home directory found
What it means
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).
Source
Thrown at komorebi-shortcuts/src/main.rs:20
use std::path::PathBuf;
use whkd_core::Whkdrc;
#[derive(Default)]
struct Quicklook {
whkdrc: Option<Whkdrc>,
filter: String,
}
impl Quicklook {
fn new(_cc: &eframe::CreationContext<'_>) -> Self {
// Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.
// Restore app state using cc.storage (requires the "persistence" feature).
// Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use
// for e.g. egui::PaintCallback.
let mut home = std::env::var("WHKD_CONFIG_HOME").map_or_else(
|_| {
dirs::home_dir()
.expect("no home directory found")
.join(".config")
},
|home_path| {
let home = PathBuf::from(&home_path);
if home.as_path().is_dir() {
home
} else {
panic!(
"$Env:WHKD_CONFIG_HOME is set to '{home_path}', which is not a valid directory",
);
}
},
);
home.push("whkdrc");
Self {
whkdrc: whkd_parser::load(&home).ok(),View on GitHub (pinned to e0709f02bf)
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
Example fix
// before
dirs::home_dir()
.expect("no home directory found")
.join(".config")
// after
dirs::home_dir()
.map(|home| home.join(".config"))
.unwrap_or_else(|| {
std::env::var("APPDATA")
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from("."))
}) Defensive patterns
Strategy: validation
Validate before calling
// PowerShell: verify resolvable config home before launching
if (-not $env:WHKD_CONFIG_HOME) {
if (-not $env:USERPROFILE) { throw "Neither WHKD_CONFIG_HOME nor USERPROFILE is set" }
}
Type guard
// Rust
fn effective_config_home() -> Option<PathBuf> {
std::env::var("WHKD_CONFIG_HOME").ok().map(PathBuf::from)
.or_else(|| dirs::home_dir().map(|h| h.join(".config")))
} Try / catch
match dirs::home_dir() {
Some(home) => configure(home.join(".config")),
None => { log::error!("no home directory found; skipping state restore"); return; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- there is no home directory
- $Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is
- there is no local data directory
- there is no home directory
- $Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is
AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06).
Data as JSON: /api/errors/64027ebee381630f.
Report an issue: GitHub.