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 `try_apply_theme`, when `KOMOREBI_CONFIG_HOME` is set, komorebi-bar expands env vars with `replace_env()` and then asserts that the resulting path `is_dir()`. The assertion `"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"` panics when the variable points to a nonexistent path or a file instead of a directory.

Source

Thrown at komorebi-bar/src/bar.rs:640

            Some(theme) => {
                apply_theme(
                    ctx,
                    theme.clone(),
                    self.bg_color.clone(),
                    self.bg_color_with_alpha.clone(),
                    self.config.transparency_alpha,
                    self.config.grouping,
                    self.render_config.clone(),
                );
            }
            None => {
                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

                    },
                );

                let bar_transparency_alpha = self.config.transparency_alpha;
                let bar_grouping = self.config.grouping;
                let config = home_dir.join("komorebi.json");
                match komorebi_client::StaticConfig::read(&config) {
                    Ok(config) => {
                        if let Some(theme) = config.theme {
                            apply_theme(
                                ctx,
                                KomobarTheme::from(theme),
                                self.bg_color.clone(),

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Verify the path exists and is a directory: run `Test-Path $Env:KOMOREBI_CONFIG_HOME -PathType Container` and fix or create the directory.
  2. Correct the value: `$Env:KOMOREBI_CONFIG_HOME = 'C:\Users\you\.config\komorebi'` (directory, not the komorebi.json file).
  3. Persist the corrected value in your profile or system environment variables so the bar always sees a valid path.
  4. If env-var expansion inside the value is intended, make sure the referenced variables are set in the same session that launches the bar.

Example fix

// before (shell setup that triggers the panic)
$Env:KOMOREBI_CONFIG_HOME = "$Env:USERPROFILE\.config\komorebi\komorebi.json"
// after
$Env:KOMOREBI_CONFIG_HOME = "$Env:USERPROFILE\.config\komorebi"
Defensive patterns

Strategy: validation

Validate before calling

# validate before launching the bar (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 is_valid_config_home(home: &Path) -> bool {
    home.is_dir()
}

Try / catch

// caller-side guard mirroring the library assert
if !home.is_dir() {
    eprintln!("KOMOREBI_CONFIG_HOME='{}' is not a valid directory", home_path);
    std::process::exit(1);
}

Prevention

When it happens

Trigger: Starting the bar with `KOMOREBI_CONFIG_HOME` set to a path that does not exist, was typo'd, points to a file, or contains env-var references that fail to expand into an existing directory — reached via `apply_config` or `update` calls to `try_apply_theme`.

Common situations: Typo in the directory name when setting the env var, pointing it at a config *file* instead of its containing directory, deleting or renaming the folder after setting the var, or setting it in a different shell/session than the one launching the bar with stale quoting.

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/0a9e7b5e6b627001. Report an issue: GitHub.