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

In komorebi-bar's `main`, a set `KOMOREBI_CONFIG_HOME` is env-expanded via `replace_env()` and validated with `assert!(home.is_dir(), ...)`. The panic message `"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"` aborts startup when the variable resolves to a nonexistent path or a non-directory file.

Source

Thrown at komorebi-bar/src/main.rs:174

    if std::env::var("RUST_LOG").is_err() {
        unsafe {
            std::env::set_var("RUST_LOG", "info");
        }
    }

    tracing::subscriber::set_global_default(
        tracing_subscriber::fmt::Subscriber::builder()
            .with_env_filter(EnvFilter::from_default_env())
            .finish(),
    )?;

    let 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
        },
    );

    if opts.quickstart {
        let komorebi_bar_json = include_str!("../../docs/komorebi.bar.example.json").to_string();
        std::fs::write(home_dir.join("komorebi.bar.json"), komorebi_bar_json)?;
        println!(
            "Example komorebi.bar.json file written to {}",
            home_dir.display()
        );

        std::process::exit(0);
    }

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Check the resolved path: `Test-Path $Env:KOMOREBI_CONFIG_HOME -PathType Container`; if false, create the directory or fix the value.
  2. Set the variable to the config *directory*: `$Env:KOMOREBI_CONFIG_HOME = "$Env:USERPROFILE\.config\komorebi"`.
  3. If the value uses nested env-var expansion, confirm those variables exist in the session launching the bar.
  4. Persist a correct value in user/system environment variables so every launch context sees a valid directory.

Example fix

// before (shell setup that triggers the assert)
$Env:KOMOREBI_CONFIG_HOME = 'C:\Users\you\.config\komorebi\komorebi.json'
// after
$Env:KOMOREBI_CONFIG_HOME = 'C:\Users\you\.config\komorebi'
Defensive patterns

Strategy: validation

Validate before calling

# validate before invoking the binary (PowerShell)
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"
}

Type guard

fn validate_config_home(home_path: &str, home: &Path) -> Result<(), String> {
    if home.is_dir() { Ok(()) }
    else { Err(format!("$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory")) }
}

Try / catch

# wrapper that fails fast with a clear message instead of a panic
if (-not (Test-Path $Env:KOMOREBI_CONFIG_HOME -PathType Container)) {
    Write-Error "Fix KOMOREBI_CONFIG_HOME: '$Env:KOMOREBI_CONFIG_HOME' is not a directory"
    exit 1
}
& komorebi-bar

Prevention

When it happens

Trigger: Launching the komorebi-bar binary with `KOMOREBI_CONFIG_HOME` pointing at a missing/typo'd path, a config file instead of a directory, or a value whose embedded env-var references expand to nothing valid — the assertion in `main` fails immediately.

Common situations: Pointing the variable at `komorebi.json` instead of its parent folder, renaming/moving the config directory without updating the env var, setting the variable in one PowerShell profile but launching the bar from another, or quoting mistakes leaving literal `$Env:` text in the value.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


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