louis-e/arnis · critical

Error while starting the application UI (Tauri)

Error message

Error while starting the application UI (Tauri)

What it means

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'.

Source

Thrown at src/gui.rs:179

            gui_get_platform,
            gui_clear_tile_caches,
            gui_get_world_map_data,
            gui_show_in_folder,
            gui_get_3d_model_attributions,
            gui_get_terrain_preview,
            gui_get_preview_landcover,
            gui_get_preview_buildings,
            gui_log
        ])
        .setup(|app| {
            let app_handle = app.handle();
            let main_window = tauri::Manager::get_webview_window(app_handle, "main")
                .expect("Failed to get main window");
            progress::set_main_window(main_window);
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("Error while starting the application UI (Tauri)");
}

/// Detects the default Minecraft Java Edition saves directory for the current OS.
/// Checks standard install paths including Flatpak on Linux.
/// Falls back to Desktop, then current directory.
fn detect_minecraft_saves_directory() -> PathBuf {
    // Try standard Minecraft saves directories per OS
    let mc_saves: Option<PathBuf> = if cfg!(target_os = "windows") {
        env::var("APPDATA")
            .ok()
            .map(|appdata| PathBuf::from(appdata).join(".minecraft").join("saves"))
    } else if cfg!(target_os = "macos") {
        dirs::home_dir().map(|home| {
            home.join("Library/Application Support/minecraft")
                .join("saves")
        })
    } else if cfg!(target_os = "linux") {
        dirs::home_dir().map(|home| {

View on GitHub (pinned to 34048924d9)

Solutions

  1. 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
  2. Build the frontend first (e.g. `npm install && npm run tauri dev` / run the beforeDevCommand/beforeBuildCommand) so frontendDist exists and generate_context! succeeds
  3. Verify tauri.conf.json: app.windows must contain a window labeled "main" and all referenced icons must exist
  4. Run with a display server available (real X11/Wayland session, or xvfb-run in CI); check DISPLAY/WAYLAND_DISPLAY env vars
  5. Read the panic's chained cause (the Err from tauri .run()) for the underlying message; fix that specific issue

Example fix

// before: window removed/renamed in tauri.conf.json
{"app": {"windows": [{"label": "primary", "title": "Arnis"}]}}
// after: keep the label the code looks up
{"app": {"windows": [{"label": "main", "title": "Arnis"}]}}
Defensive patterns

Strategy: try-catch

Validate before calling

fn can_start_gui() -> bool {
    // webview runtime present (Linux) and a display server available
    !cfg!(target_os = "linux")
        || (std::env::var("DISPLAY").is_ok() || std::env::var("WAYLAND_DISPLAY").is_ok())
}

Type guard

fn has_main_window(app: &tauri::App) -> bool {
    tauri::Manager::get_webview_window(app.handle(), "main").is_some()
}

Try / catch

match tauri::Builder::default()
    .setup(|app| { /* ... */ Ok(()) })
    .run(tauri::generate_context!())
{
    Ok(()) => {}
    Err(e) => {
        eprintln!("Failed to start UI: {e}");
        // fall back to CLI mode or show a dialog, don't panic
        std::process::exit(1);
    }
}

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of louis-e/arnis@34048924d9 (2026-09-03). Data as JSON: /api/errors/9a8fe8000bda0dd3. Report an issue: GitHub.