{"record":{"id":"609dd061bce86dc4","repo":"slint-ui/slint","slug":"error-compiling-keymap","errorCode":null,"errorMessage":"Error compiling keymap","messagePattern":"Error compiling keymap","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/linuxkms/calloop_backend/input.rs","lineNumber":328,"sourceCode":"                        let pos = take_touch_pos(&mut self.last_touch_positions, slot);\n                        window.dispatch_event(WindowEvent::internal(InternalEvent::Touch {\n                            id: slot,\n                            position: logical_point_from_api(pos),\n                            phase: i_slint_core::input::TouchPhase::Cancelled,\n                        }));\n                    }\n                    _ => {}\n                },\n                input::Event::Keyboard(input::event::KeyboardEvent::Key(key_event)) => {\n                    // On Linux key codes have a fixed offset of 8: https://docs.rs/xkbcommon/0.6.0/xkbcommon/xkb/struct.Keycode.html\n                    let key_code = xkb::Keycode::new(key_event.key() + 8);\n                    let state = key_event.key_state();\n\n                    let xkb_key_state = self.keystate.get_or_insert_with(|| {\n                        let xkb_context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);\n                        let keymap =\n                            xkb::Keymap::new_from_names(&xkb_context, \"\", \"\", \"\", \"\", None, 0)\n                                .expect(\"Error compiling keymap\");\n                        xkb::State::new(&keymap)\n                    });\n\n                    let sym = xkb_key_state.key_get_one_sym(key_code);\n\n                    xkb_key_state.update_key(\n                        key_code,\n                        match state {\n                            input::event::tablet_pad::KeyState::Pressed => xkb::KeyDirection::Down,\n                            input::event::tablet_pad::KeyState::Released => xkb::KeyDirection::Up,\n                        },\n                    );\n\n                    let control = xkb_key_state\n                        .mod_name_is_active(xkb::MOD_NAME_CTRL, xkb::STATE_MODS_EFFECTIVE);\n                    let alt = xkb_key_state\n                        .mod_name_is_active(xkb::MOD_NAME_ALT, xkb::STATE_MODS_EFFECTIVE);\n","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/linuxkms/calloop_backend/input.rs#L310-L346","documentation":"In the linuxkms backend's calloop input handling, the first key event lazily creates an xkbcommon `Keymap` via `Keymap::new_from_names` with empty RMLVO names (using libxkbcommon defaults). If libxkbcommon cannot compile a keymap from those defaults, the code panics with \"Error compiling keymap\". This means no usable keyboard layout could be constructed for the session.","triggerScenarios":"Receiving a key event in `process_events` when `keystate` is not yet initialized and `xkb::Keymap::new_from_names(&ctx, \"\", \"\", \"\", \"\", None, 0)` fails — typically when the libxkbcommon data files (keycodes/types/compat/symbols) are missing or the xkbcommon build can't produce a default keymap.","commonSituations":"Minimal or embedded Linux systems (kiosks, automotive HMI, embedded boards) without /usr/share/X11/xkb data or with a stripped libxkbcommon; broken XKB_CONFIG/XKB_DATADIR environment; musl/embedded builds missing keymap data packages.","solutions":["Install the xkeyboard-config data files (e.g. `apt install xkb-data` or the distro equivalent) so libxkbcommon can compile the default keymap.","Verify libxkbcommon was built with keymap-from-names support and that XKB data path env vars (XKB_DATADIR/XKB_CONFIG_ROOT) point to valid data.","Explicitly pass a known-good layout/model/rules to `Keymap::new_from_names` instead of empty strings in a patched backend build.","As a workaround, supply a compiled keymap file via `Keymap::new_from_string` and adjust the backend to use it."],"exampleFix":"// before\nlet keymap = xkb::Keymap::new_from_names(&xkb_context, \"\", \"\", \"\", \"\", None, 0)\n    .expect(\"Error compiling keymap\");\n\n// after: fail gracefully / fall back\nlet keymap = xkb::Keymap::new_from_names(&xkb_context, \"\", \"\", \"\", \"\", None, 0)\n    .or_else(|| {\n        let rules = std::fs::read_to_string(\"/custom/keymap.xkb\").ok()?;\n        xkb::Keymap::new_from_string(&xkb_context, rules, xkb::KEYMAP_FORMAT_TEXT_V1, xkb::KEYMAP_COMPILE_NO_FLAGS)\n    })\n    .unwrap_or_else(|| eprintln!(\"xkbcommon keymap unavailable; keyboard input disabled\"));","handlingStrategy":"fallback","validationCode":"// probe keymap compilability before running keyboard-dependent code\nlet probe = xkb::Context::new(xkb::CONTEXT_NO_FLAGS)\n    .and_check();\n// on embedded targets, verify /usr/share/X11/xkb exists at startup\nassert!(std::path::Path::new(\"/usr/share/X11/xkb\").exists(), \"xkb data missing\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include xkeyboard-config data files in embedded/kiosk images","Smoke-test keymap compilation early at boot, before user input is expected","Pin and verify the libxkbcommon build and its data path env vars in CI for embedded targets"],"tags":["linuxkms","xkbcommon","keyboard","embedded"],"backgroundTag":"module-init-failed","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}