LGUG2Z/komorebi · error

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

Error message

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

What it means

whkd resolves its config directory from the WHKD_CONFIG_HOME environment variable. If that variable is set but points to a path that is not an existing directory, new() panics with this message instead of silently using a bad path.

Source

Thrown at komorebi-shortcuts/src/main.rs:29

impl Quicklook {
    fn new(_cc: &eframe::CreationContext<'_>) -> Self {
        // Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.
        // Restore app state using cc.storage (requires the "persistence" feature).
        // Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use
        // for e.g. egui::PaintCallback.
        let mut home = std::env::var("WHKD_CONFIG_HOME").map_or_else(
            |_| {
                dirs::home_dir()
                    .expect("no home directory found")
                    .join(".config")
            },
            |home_path| {
                let home = PathBuf::from(&home_path);

                if home.as_path().is_dir() {
                    home
                } else {
                    panic!(
                        "$Env:WHKD_CONFIG_HOME is set to '{home_path}', which is not a valid directory",
                    );
                }
            },
        );
        home.push("whkdrc");

        Self {
            whkdrc: whkd_parser::load(&home).ok(),
            filter: String::new(),
        }
    }
}

impl eframe::App for Quicklook {
    fn update(&mut self, ctx: &eframe::egui::Context, _frame: &mut eframe::Frame) {
        eframe::egui::CentralPanel::default().show(ctx, |ui| {
            ui.set_max_width(ui.available_width());

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Verify the path exists and is a directory: Test-Path $Env:WHKD_CONFIG_HOME -PathType Container.
  2. Fix or remove the variable: set $Env:WHKD_CONFIG_HOME to the folder containing whkdrc, or unset it to fall back to the default location.
  3. Create the directory if it is missing: New-Item -ItemType Directory -Force $Env:WHKD_CONFIG_HOME.

Example fix

// before
$Env:WHKD_CONFIG_HOME = "C:\Users\me\.config\whkd"
// (folder was deleted)
// after
New-Item -ItemType Directory -Force "$HOME\.config\whkd"
Copy-Item whkdrc "$HOME\.config\whkd\"
Defensive patterns

Strategy: validation

Validate before calling

if ($env:WHKD_CONFIG_HOME -and -not (Test-Path $env:WHKD_CONFIG_HOME -PathType Container)) { throw "WHKD_CONFIG_HOME is not a valid directory" }

Type guard

fn valid_config_home(home_path: &str) -> bool {
    std::path::Path::new(home_path).is_dir()
}

Try / catch

std::panic::catch_unwind(whkd::config::Config::new).map_err(|_| anyhow!("check $Env:WHKD_CONFIG_HOME points to an existing directory"))

Prevention

When it happens

Trigger: Setting $Env:WHKD_CONFIG_HOME to a path that does not exist, was deleted, is a file rather than a directory, or contains a typo before launching whkd.

Common situations: Environment variable left over after moving/deleting the config folder; mistyped path; WHKD_CONFIG_HOME pointing to a file (e.g. the whkdrc itself instead of its folder); USB/network drive not mounted.

Related errors


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