{"record":{"id":"2d2f68efa10e297b","repo":"iced-rs/iced","slug":"create-event-loop","errorCode":null,"errorMessage":"Create event loop","messagePattern":"Create event loop","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"winit/src/lib.rs","lineNumber":83,"sourceCode":"use std::mem::ManuallyDrop;\nuse std::slice;\nuse std::sync::Arc;\n\n/// Runs a [`Program`] with the provided settings.\npub fn run<P>(program: P) -> Result<(), Error>\nwhere\n    P: Program + 'static,\n    P::Theme: theme::Base,\n{\n    use winit::event_loop::EventLoop;\n\n    let boot_span = debug::boot();\n    let settings = program.settings();\n    let window_settings = program.window();\n\n    let event_loop = EventLoop::with_user_event()\n        .build()\n        .expect(\"Create event loop\");\n\n    let backend_settings = backend::Settings::from(&settings);\n    let renderer_settings = renderer::Settings::from(&settings);\n    let display_handle = event_loop.owned_display_handle();\n\n    let (proxy, worker) = Proxy::new(event_loop.create_proxy());\n\n    #[cfg(feature = \"debug\")]\n    {\n        let proxy = proxy.clone();\n\n        debug::on_hotpatch(move || {\n            proxy.send_action(Action::Reload);\n        });\n    }\n\n    let mut runtime = {\n        let executor = P::Executor::new().map_err(Error::ExecutorCreationFailed)?;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/iced-rs/iced/blob/fa3bae52874274c012a27d4bf11a83c49e1709ae/winit/src/lib.rs#L65-L101","documentation":"The winit runtime panics when EventLoop::with_user_event().build() fails inside iced's run function. winit cannot create the platform event loop when the display server is unavailable or the platform is unsupported; iced treats a missing event loop as fatal because no GUI can run without it.","triggerScenarios":"Calling iced run/application (winit backend) in an environment with no display: no DISPLAY/WAYLAND_DISPLAY on Linux, running in a headless CI container, SSH session without X forwarding, or a winit platform feature not compiled in.","commonSituations":"CI pipelines and Docker containers without X11/Wayland; WSL setups missing WSLg; tests invoking run() during cargo test; embedded/cross-compiled targets lacking winit support.","solutions":["Run in an environment with a display server; on Linux set DISPLAY or WAYLAND_DISPLAY correctly.","In CI/headless, use xvfb-run (Xvfb) or skip GUI startup in tests.","For WSL, ensure WSLg is enabled (Windows 11) or run an X server and export DISPLAY.","Verify winit's required platform features are enabled in your Cargo features/dependencies.","Check iced/winit versions for compatibility with your target platform."],"exampleFix":"// before (CI)\ncargo test\n// after (CI)\nxvfb-run -a cargo test","handlingStrategy":"fallback","validationCode":"// shell preflight\n[ -n \"$DISPLAY\" ] || [ -n \"$WAYLAND_DISPLAY\" ] || { echo \"no display server\"; exit 1; }","typeGuard":null,"tryCatchPattern":"// probe display availability before starting the GUI loop\nfn has_display() -> bool {\n    std::env::var_os(\"WAYLAND_DISPLAY\").is_some()\n        || std::env::var_os(\"DISPLAY\").is_some()\n        || cfg!(target_os = \"windows\")\n        || cfg!(target_os = \"macos\")\n}\nif !has_display() { eprintln!(\"No display available; running headless\"); return; }","preventionTips":["Never call iced::run() in headless tests or CI; use xvfb-run or factor logic out of the GUI.","Verify DISPLAY/WAYLAND_DISPLAY in deployment scripts.","For WSL, confirm WSLg or an X server is configured.","Fail fast with a clear message instead of a panic path."],"tags":["winit","event-loop","display","headless","panic"],"backgroundTag":"unsupported-platform","analyzedSha":"fa3bae52874274c012a27d4bf11a83c49e1709ae","analyzedAt":"2026-09-11T16:54:14.229Z","contentChangedAt":"2026-09-11T16:54:14.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}