LGUG2Z/komorebi · critical
there is no local data directory
Error message
there is no local data directory
What it means
DATA_DIR is a lazily-initialized static computed once from dirs::data_local_dir(). If the OS provides no local data directory (e.g. HOME/profile environment broken), the expect panics with this message at first access of DATA_DIR. This happens on Windows when the %LOCALAPPDATA% env var is unset, or on Unix when XDG_DATA_HOME and HOME are both missing.
Source
Thrown at komorebi/src/lib.rs:213
Arc::new(Mutex::new(HashMap::new()));
static ref TCP_CONNECTIONS: Arc<Mutex<HashMap<String, TcpStream>>> =
Arc::new(Mutex::new(HashMap::new()));
static ref HIDING_BEHAVIOUR: Arc<Mutex<HidingBehaviour>> =
Arc::new(Mutex::new(HidingBehaviour::Cloak));
pub static ref HOME_DIR: PathBuf = {
std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(|_| dirs::home_dir().expect("there is no home directory"), |home_path| {
let home = home_path.replace_env();
assert!(
home.is_dir(),
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
);
home
})
};
pub static ref DATA_DIR: PathBuf = dirs::data_local_dir().expect("there is no local data directory").join("komorebi");
pub static ref AHK_EXE: String = {
let mut ahk: String = String::from("autohotkey.exe");
if let Ok(komorebi_ahk_exe) = std::env::var("KOMOREBI_AHK_EXE")
&& which(&komorebi_ahk_exe).is_ok() {
ahk = komorebi_ahk_exe;
}
ahk
};
static ref WINDOWS_11: bool = {
matches!(
os_info::get().version(),
Version::Semantic(_, _, x) if x >= &22000
)
};
// Use app-specific titlebar removal options where possibleView on GitHub (pinned to e0709f02bf)
Solutions
- Ensure %LOCALAPPDATA% (Windows) or $HOME / $XDG_DATA_HOME (Unix) is set for the process launching komorebi
- Re-create the user profile environment variables if they were lost
- Run komorebi as an interactive user, not under a system account with no profile
- If vendoring, replace the expect with a fallback path and log a clear error instead of panicking
Example fix
// before
pub static ref DATA_DIR: PathBuf = dirs::data_local_dir().expect("there is no local data directory").join("komorebi");
// after
pub static ref DATA_DIR: PathBuf = dirs::data_local_dir().unwrap_or_else(|| {
std::env::var_os("LOCALAPPDATA").map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from(".")).join("komorebi")
}); Defensive patterns
Strategy: validation
Validate before calling
if std::env::var_os("LOCALAPPDATA").is_none() && std::env::var_os("HOME").is_none() {
panic!("no local data directory: set LOCALAPPDATA or HOME before starting");
} Prevention
- Always launch komorebi from an interactive user session with a normal environment
- Verify %LOCALAPPDATA% exists before automating komorebi launches
- Avoid running komorebi under system/service accounts without user profiles
When it happens
Trigger: First access of DATA_DIR (komorebi/src/lib.rs:213) while dirs::data_local_dir() returns None, typically because KOMOREBI runs in an environment where the per-user local app-data path cannot be resolved.
Common situations: Running komorebi from a service/scheduler context with a stripped environment; broken %LOCALAPPDATA% on Windows after user profile issues; Unix-like CI shells with no HOME or XDG_DATA_HOME.
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
- no home directory found
- there is no home directory
- unable to get exec path
- there is no local data directory
- there is no home directory
AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06).
Data as JSON: /api/errors/87c3702d796189bd.
Report an issue: GitHub.