{"record":{"id":"eec071f7e35ce810","repo":"LGUG2Z/komorebi","slug":"could-not-load-configuration","errorCode":null,"errorMessage":"could not load configuration","messagePattern":"could not load configuration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"komorebi/src/main.rs","lineNumber":304,"sourceCode":"    } else {\n        Arc::new(Mutex::new(WindowManager::new(\n            winevent_listener::event_rx(),\n            None,\n        )?))\n    };\n\n    wm.lock().init()?;\n\n    if let Some(config) = &static_config {\n        StaticConfig::postload(config, &wm)?;\n    }\n\n    if !opts.await_configuration && !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {\n        INITIAL_CONFIGURATION_LOADED.store(true, Ordering::SeqCst);\n    };\n\n    if static_config.is_none() {\n        std::thread::spawn(|| load_configuration().expect(\"could not load configuration\"));\n\n        if opts.await_configuration {\n            let backoff = Backoff::new();\n            while !INITIAL_CONFIGURATION_LOADED.load(Ordering::SeqCst) {\n                backoff.snooze();\n            }\n        }\n    }\n\n    let dumped_state = temp_dir().join(\"komorebi.state.json\");\n\n    if !opts.clean_state && dumped_state.is_file() {\n        if let Ok(state) = serde_json::from_str(&std::fs::read_to_string(&dumped_state)?) {\n            wm.lock().apply_state(state);\n        } else {\n            tracing::warn!(\n                \"cannot apply state from {}; state struct is not up to date\",\n                dumped_state.display()","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi/src/main.rs#L286-L322","documentation":"In main, when no static configuration was loaded at startup, komorebi spawns a thread running load_configuration().expect(...). If load_configuration returns Err (config file missing/unparseable), the spawned thread panics with 'could not load configuration' and the window manager starts without any user configuration (or hangs forever in the await_configuration backoff loop).","triggerScenarios":"StaticConfig is None at startup and load_configuration() fails: komorebi.json absent from $HOME/.config/komorebi or $KOMOREBI_CONFIG_HOME, path set but unreadable, or JSON contains schema-invalid values.","commonSituations":"First install without a komorebi.json; KOMOREBI_CONFIG_HOME pointing to a nonexistent directory; a typo'd or schema-invalid config after upgrading komorebi.","solutions":["Create a valid komorebi.json at ~/.config/komorebi/komorebi.json or generate one with `komorebi-bar`/docs sample","Set KOMOREBI_CONFIG_HOME to a directory that contains komorebi.json","Validate the JSON (schema check / jq .) and fix schema violations","If you intentionally run configless, ensure the config path resolution logic finds nothing but load_configuration handles that gracefully rather than erroring"],"exampleFix":"// before\nstd::thread::spawn(|| load_configuration().expect(\"could not load configuration\"));\n// after\nstd::thread::spawn(|| {\n    if let Err(e) = load_configuration() {\n        tracing::error!(\"could not load configuration: {e}\");\n    }\n});","handlingStrategy":"validation","validationCode":"let path = std::env::var(\"KOMOREBI_CONFIG_HOME\")\n    .map(std::path::PathBuf::from)\n    .unwrap_or_else(|_| dirs::home_dir().unwrap().join(\".config/komorebi\"));\nlet cfg = path.join(\"komorebi.json\");\nassert!(cfg.exists(), \"config missing at {cfg:?}\");\nlet _: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(cfg).unwrap())\n    .expect(\"config is not valid JSON\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate komorebi.json with the published JSON schema after every edit","Set KOMOREBI_CONFIG_HOME explicitly and confirm the file exists before launch","Start from the official sample config rather than a blank file"],"tags":["config","panic","json","windows"],"backgroundTag":"config-file-not-found","analyzedSha":"e0709f02bfae4e503bf4640f58ee75ecbbfdbb97","analyzedAt":"2026-09-06T07:08:05.107Z","contentChangedAt":"2026-09-06T07:08:05.107Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}