{"record":{"id":"9c06f6489975dfba","repo":"zed-industries/zed","slug":"libxkbcommon-failed-to-create-an-xkb-context","errorCode":null,"errorMessage":"libxkbcommon failed to create an XKB context","messagePattern":"libxkbcommon failed to create an XKB context","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/platform.rs","lineNumber":913,"sourceCode":"\n#[cfg(any(feature = \"wayland\", feature = \"x11\"))]\npub(super) fn is_within_click_distance(a: Point<Pixels>, b: Point<Pixels>) -> bool {\n    let diff = a - b;\n    diff.x.abs() <= DOUBLE_CLICK_DISTANCE && diff.y.abs() <= DOUBLE_CLICK_DISTANCE\n}\n\n/// Creates an XKB context for keymaps supplied by Wayland or X11.\n///\n/// Server keymaps are already resolved and need no local keyboard definitions.\n/// Loading default include paths can fail on systems without those files.\n#[cfg(any(feature = \"wayland\", feature = \"x11\"))]\npub(super) fn new_xkb_context() -> anyhow::Result<xkb::Context> {\n    validate_xkb_context(xkb::Context::new(xkb::CONTEXT_NO_DEFAULT_INCLUDES))\n}\n\n#[cfg(any(feature = \"wayland\", feature = \"x11\"))]\nfn validate_xkb_context(context: xkb::Context) -> anyhow::Result<xkb::Context> {\n    ensure!(\n        !context.get_raw_ptr().is_null(),\n        \"libxkbcommon failed to create an XKB context\"\n    );\n    Ok(context)\n}\n\n#[cfg(any(feature = \"wayland\", feature = \"x11\"))]\npub(super) fn get_xkb_compose_state(cx: &xkb::Context) -> Option<xkb::compose::State> {\n    let mut locales = Vec::default();\n    if let Some(locale) = env::var_os(\"LC_CTYPE\") {\n        locales.push(locale);\n    }\n    locales.push(OsString::from(\"C\"));\n    let mut state: Option<xkb::compose::State> = None;\n    for locale in locales {\n        if let Ok(table) =\n            xkb::compose::Table::new_from_locale(cx, &locale, xkb::compose::COMPILE_NO_FLAGS)\n        {","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/platform.rs#L895-L931","documentation":"Guard in validate_xkb_context: libxkbcommon returned a null/invalid xkb_context, so keyboard mapping, key event translation, and IME cannot be initialized for the Wayland/X11 backend. Fires when libxkbcommon is missing, too old, or cannot allocate its context (e.g. broken XKB data files in /usr/share/xkb).","triggerScenarios":"Thrown at crates/gpui_linux/src/linux/platform.rs:847 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install or upgrade libxkbcommon and verify /usr/share/xkb keymap data exists","Check XDG_DATA_DIRS / XKB_CONFIG_ROOT overrides that hide xkbcommon's data files","Propagate the error so the platform reports keyboard initialization failure instead of proceeding with a null context"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}