LGUG2Z/komorebi · error

unsupported format

Error message

unsupported format

What it means

KomobarConfig::read loads a komobar configuration file and only supports JSON. If the file's extension is anything other than "json", the match falls through to an explicit panic!("unsupported format"). YAML/other formats are simply not implemented for komobar config.

Source

Thrown at komorebi-bar/src/config.rs:512

            MouseMessage::Command(cmd) => {
                tracing::debug!("Executing command: {}", cmd);

                let cmd_no_env = cmd.replace_env();

                if exec_powershell(cmd_no_env.to_str().expect("Invalid command")).is_err() {
                    tracing::error!("Failed to execute '{}'", cmd);
                }
            }
        };
    }
}

impl KomobarConfig {
    pub fn read(path: &PathBuf) -> color_eyre::Result<Self> {
        let content = std::fs::read_to_string(path)?;
        let mut value: Self = match path.extension().unwrap().to_string_lossy().as_str() {
            "json" => serde_json::from_str(&content)?,
            _ => panic!("unsupported format"),
        };

        if value.frame.is_none() {
            value.frame = Some(FrameConfig {
                inner_margin: Position {
                    x: DEFAULT_PADDING,
                    y: DEFAULT_PADDING,
                },
            });
        }

        Ok(value)
    }
}

#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
/// Position

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Rename the komobar config file so it ends in .json (komobar.json).
  2. If the file is YAML, convert it to JSON (e.g. yq -o=json komobar.yaml > komobar.json).
  3. Ensure the path passed to KomobarConfig::read points at the .json file, and has an extension at all.

Example fix

// before
komorebi.panic? -> $Env:KOMOBAR_CONFIG_HOME = "C:\Users\me\.config\komobar.yaml"
// after
$Env:KOMOBAR_CONFIG_HOME = "C:\Users\me\.config\komobar.json"
Defensive patterns

Strategy: validation

Validate before calling

let path = PathBuf::from(config_path);
assert_eq!(path.extension().map(|e| e.to_string_lossy().to_lowercase()).as_deref(), Some("json"), "komobar config must be a .json file");

Type guard

fn is_json_config(path: &std::path::Path) -> bool {
    path.extension().map(|e| e.eq_ignore_ascii_case("json")).unwrap_or(false)
}

Try / catch

match std::panic::catch_unwind(|| KomobarConfig::read(&path)) {
    Ok(cfg) => cfg,
    Err(_) => eprintln!("config must be .json; got {}", path.display()),
}

Prevention

When it happens

Trigger: Calling KomobarConfig::read with a path whose extension is not "json" (e.g. komobar.yml, komobar.yaml, komobar.toml, or no extension). Also note the unwrap on path.extension(): a path with no extension panics before this message ever fires.

Common situations: Users copying the YAML config style used elsewhere in komorebi (komorebi.json/.yaml support) and creating komobar.yaml; typos in the config filename; renaming the file without the .json extension.

Related errors


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