LGUG2Z/komorebi · critical

there is no home directory

Error message

there is no home directory

What it means

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.

Source

Thrown at komorebi/src/lib.rs:201

            kind: ApplicationIdentifier::Exe,
            id: String::from("firefox.exe"),
            matching_strategy: Option::from(MatchingStrategy::Equals),
        }),
    ]));
    static ref DUPLICATE_MONITOR_SERIAL_IDS: Arc<RwLock<Vec<String>>> =
        Arc::new(RwLock::new(Vec::new()));
    static ref SUBSCRIPTION_PIPES: Arc<Mutex<HashMap<String, File>>> =
        Arc::new(Mutex::new(HashMap::new()));
    pub static ref SUBSCRIPTION_SOCKETS: Arc<Mutex<HashMap<String, PathBuf>>> =
        Arc::new(Mutex::new(HashMap::new()));
    pub static ref SUBSCRIPTION_SOCKET_OPTIONS: Arc<Mutex<HashMap<String, SubscribeOptions>>> =
        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;

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Set KOMOREBI_CONFIG_HOME to an existing directory so the home-dir fallback is never used
  2. Ensure the USERPROFILE environment variable is set and points to an existing directory before launching komorebi
  3. Launch komorebi from a normal interactive user session, not a service/scheduler context with a stripped environment
  4. Repair the Windows user profile if the profile directory is missing or renamed

Example fix

// before (PowerShell wrapper)
komorebic start -a whkd
// after (PowerShell wrapper)
$env:KOMOREBI_CONFIG_HOME = "$env:USERPROFILE\.config"
if (-not (Test-Path $env:KOMOREBI_CONFIG_HOME)) { throw "config home missing" }
komorebic start -a whkd
Defensive patterns

Strategy: validation

Validate before calling

// PowerShell preflight before starting komorebi
if (-not $env:KOMOREBI_CONFIG_HOME -and -not $env:USERPROFILE) {
  throw "Set KOMOREBI_CONFIG_HOME; no home directory is resolvable"
}

Type guard

// Rust
fn resolve_home() -> Option<PathBuf> {
    std::env::var("KOMOREBI_CONFIG_HOME").ok().map(PathBuf::from)
        .or_else(|| dirs::home_dir())
        .filter(|p| p.is_dir())
}

Try / catch

// Downstream code can avoid touching a bad HOME_DIR by pre-checking
std::env::var("KOMOREBI_CONFIG_HOME")
    .or_else(|_| std::env::var("USERPROFILE"))
    .map(PathBuf::from)
    .filter(|p| p.is_dir())
    .ok_or_else(|| anyhow!("no valid home/config directory available"))?;

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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


AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06). Data as JSON: /api/errors/8ea3eba0abbbad65. Report an issue: GitHub.