LGUG2Z/komorebi · error

$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is

Error message

$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory

What it means

When KOMOREBI_CONFIG_HOME is set, komorebi validates that the resolved path is an existing directory via assert!(home.is_dir()) inside the HOME_DIR initializer. If the variable points at a nonexistent path or a file, the assertion panics with this interpolated message. This is fail-fast validation of a user-provided configuration directory.

Source

Thrown at komorebi/src/lib.rs:206

    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;
            }

        ahk
    };
    static ref WINDOWS_11: bool = {

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Create the directory the variable points to (mkdir $Env:KOMOREBI_CONFIG_HOME) or run `komorebic quickstart` to regenerate a config
  2. Fix the KOMOREBI_CONFIG_HOME value to point at the real config directory containing config.json
  3. Temporarily unset KOMOREBI_CONFIG_HOME so komorebi falls back to ~/.config/komorebi
  4. Verify the path is a directory, not a file, and that any embedded env vars in the value expand correctly (komorebi applies replace_env to it)

Example fix

// before (PowerShell)
$env:KOMOREBI_CONFIG_HOME = "C:\Users\me\.config\komorebi-old"
// after (PowerShell)
$env:KOMOREBI_CONFIG_HOME = "C:\Users\me\.config\komorebi"
if (-not (Test-Path $env:KOMOREBI_CONFIG_HOME -PathType Container)) {
  komorebic quickstart
}
Defensive patterns

Strategy: validation

Validate before calling

// PowerShell: validate KOMOREBI_CONFIG_HOME before starting komorebi
if ($env:KOMOREBI_CONFIG_HOME -and -not (Test-Path $env:KOMOREBI_CONFIG_HOME -PathType Container)) {
  throw "KOMOREBI_CONFIG_HOME='$($env:KOMOREBI_CONFIG_HOME)' is not a valid directory"
}
komorebic start -a whkd

Type guard

// Rust
fn valid_config_home(home_path: &str) -> bool {
    PathBuf::from(home_path.replace_env()).is_dir()
}

Try / catch

// Downstream: resolve without triggering the panic
match std::env::var("KOMOREBI_CONFIG_HOME") {
    Ok(p) if PathBuf::from(&p).is_dir() => Some(PathBuf::from(p)),
    Ok(p) => { log::error!("KOMOREBI_CONFIG_HOME='{p}' is not a valid directory"); None }
    Err(_) => dirs::home_dir().map(|h| h.join(".config")),
}

Prevention

When it happens

Trigger: KOMOREBI_CONFIG_HOME is set to a path that does not exist, was deleted, contains a typo, includes unexpanded environment variables that resolve to nothing, or points to a regular file instead of a directory.

Common situations: Typo'd path in PowerShell $PROFILE (e.g. missing backslash); moving/renaming the config folder after setting the variable; using a forward-slash or quoted path that resolves incorrectly; setting the variable system-wide but never creating the directory; variable set on a machine where the config was never bootstrapped (komorebic quickstart).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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