{"record":{"id":"9a8fe8000bda0dd3","repo":"louis-e/arnis","slug":"error-while-starting-the-application-ui-tauri","errorCode":null,"errorMessage":"Error while starting the application UI (Tauri)","messagePattern":"Error while starting the application UI \\(Tauri\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/gui.rs","lineNumber":179,"sourceCode":"            gui_get_platform,\n            gui_clear_tile_caches,\n            gui_get_world_map_data,\n            gui_show_in_folder,\n            gui_get_3d_model_attributions,\n            gui_get_terrain_preview,\n            gui_get_preview_landcover,\n            gui_get_preview_buildings,\n            gui_log\n        ])\n        .setup(|app| {\n            let app_handle = app.handle();\n            let main_window = tauri::Manager::get_webview_window(app_handle, \"main\")\n                .expect(\"Failed to get main window\");\n            progress::set_main_window(main_window);\n            Ok(())\n        })\n        .run(tauri::generate_context!())\n        .expect(\"Error while starting the application UI (Tauri)\");\n}\n\n/// Detects the default Minecraft Java Edition saves directory for the current OS.\n/// Checks standard install paths including Flatpak on Linux.\n/// Falls back to Desktop, then current directory.\nfn detect_minecraft_saves_directory() -> PathBuf {\n    // Try standard Minecraft saves directories per OS\n    let mc_saves: Option<PathBuf> = if cfg!(target_os = \"windows\") {\n        env::var(\"APPDATA\")\n            .ok()\n            .map(|appdata| PathBuf::from(appdata).join(\".minecraft\").join(\"saves\"))\n    } else if cfg!(target_os = \"macos\") {\n        dirs::home_dir().map(|home| {\n            home.join(\"Library/Application Support/minecraft\")\n                .join(\"saves\")\n        })\n    } else if cfg!(target_os = \"linux\") {\n        dirs::home_dir().map(|home| {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/louis-e/arnis/blob/34048924d9365795fb0d832e76140a3fbdc413d9/src/gui.rs#L161-L197","documentation":"run_gui builds the Tauri application and calls .run(tauri::generate_context!()). When Tauri's event loop fails to start — invalid tauri.conf.json, a missing/unusable runtime (e.g. no WebKit/GTK on Linux, missing WebView2 on Windows), port/window-creation failures, or an error returned by the setup hook — run returns Err and this expect panics with 'Error while starting the application UI (Tauri)'. The same panic also fires if the setup hook panicked earlier at 'Failed to get main window'.","triggerScenarios":"Calling run_gui when: tauri.conf.json is missing fields or references a missing icon/frontend dist; the system lacks the webview runtime (libwebkit2gtk not installed, WebView2 absent); window labeled 'main' is absent from the config so get_webview_window in setup returns None; another fatal Tauri runtime error is returned by .run().","commonSituations":"Running the GUI in a headless Docker/CI container or over SSH with no display; deploying to a fresh Linux machine without webkit2gtk-4.1; a broken build where the frontendDist assets were not generated (frontend not built before cargo build); editing tauri.conf.json and removing or renaming the 'main' window.","solutions":["Install the required webview runtime: on Debian/Ubuntu `sudo apt install libwebkit2gtk-4.1-dev build-essential libgtk-3-dev`; on Windows ensure WebView2 Runtime is installed","Build the frontend first (e.g. `npm install && npm run tauri dev` / run the beforeDevCommand/beforeBuildCommand) so frontendDist exists and generate_context! succeeds","Verify tauri.conf.json: app.windows must contain a window labeled \"main\" and all referenced icons must exist","Run with a display server available (real X11/Wayland session, or xvfb-run in CI); check DISPLAY/WAYLAND_DISPLAY env vars","Read the panic's chained cause (the Err from tauri .run()) for the underlying message; fix that specific issue"],"exampleFix":"// before: window removed/renamed in tauri.conf.json\n{\"app\": {\"windows\": [{\"label\": \"primary\", \"title\": \"Arnis\"}]}}\n// after: keep the label the code looks up\n{\"app\": {\"windows\": [{\"label\": \"main\", \"title\": \"Arnis\"}]}}","handlingStrategy":"try-catch","validationCode":"fn can_start_gui() -> bool {\n    // webview runtime present (Linux) and a display server available\n    !cfg!(target_os = \"linux\")\n        || (std::env::var(\"DISPLAY\").is_ok() || std::env::var(\"WAYLAND_DISPLAY\").is_ok())\n}","typeGuard":"fn has_main_window(app: &tauri::App) -> bool {\n    tauri::Manager::get_webview_window(app.handle(), \"main\").is_some()\n}","tryCatchPattern":"match tauri::Builder::default()\n    .setup(|app| { /* ... */ Ok(()) })\n    .run(tauri::generate_context!())\n{\n    Ok(()) => {}\n    Err(e) => {\n        eprintln!(\"Failed to start UI: {e}\");\n        // fall back to CLI mode or show a dialog, don't panic\n        std::process::exit(1);\n    }\n}","preventionTips":["Keep the window labeled \"main\" present in tauri.conf.json — setup depends on it","Ensure webkit2gtk-4.1 (Linux) / WebView2 Runtime (Windows) is installed before distributing","Always run beforeBuildCommand so frontendDist assets exist before cargo build","Never launch the GUI in headless environments; check DISPLAY/WAYLAND_DISPLAY first","Log the inner Err from tauri .run() instead of only the expect message"],"tags":["tauri","gui-startup","panic","rust","missing-dependency"],"backgroundTag":"tauri-app-failed-to-start","analyzedSha":"34048924d9365795fb0d832e76140a3fbdc413d9","analyzedAt":"2026-09-03T14:05:17.283Z","contentChangedAt":"2026-09-03T14:05:17.283Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}