{"record":{"id":"293fbc8da37f2d81","repo":"RightNow-AI/openfang","slug":"failed-to-build-tauri-application","errorCode":null,"errorMessage":"Failed to build Tauri application","messagePattern":"Failed to build Tauri application","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/openfang-desktop/src/lib.rs","lineNumber":201,"sourceCode":"            });\n\n            // Spawn startup update check (desktop only, after event forwarding is set up)\n            #[cfg(desktop)]\n            updater::spawn_startup_check(app.handle().clone());\n\n            info!(\"OpenFang Desktop window created\");\n            Ok(())\n        })\n        .on_window_event(|window, event| {\n            // Hide to tray on close instead of quitting (desktop)\n            #[cfg(desktop)]\n            if let tauri::WindowEvent::CloseRequested { api, .. } = event {\n                let _ = window.hide();\n                api.prevent_close();\n            }\n        })\n        .build(tauri::generate_context!())\n        .expect(\"Failed to build Tauri application\")\n        .run(|_app, event| {\n            if let tauri::RunEvent::ExitRequested { .. } = event {\n                info!(\"Tauri app exit requested\");\n            }\n        });\n\n    // App event loop has ended — shut down the embedded server + kernel\n    info!(\"Tauri app closed, shutting down embedded server...\");\n    server_handle.shutdown();\n}\n","sourceCodeStart":183,"sourceCodeEnd":212,"githubUrl":"https://github.com/RightNow-AI/openfang/blob/acf2587e46be174c10200489c9a2d23a39a98aeb/crates/openfang-desktop/src/lib.rs#L183-L212","documentation":"`run()` finishes setting up the Tauri app (plugins, window builder, event handlers) and calls `.build(tauri::generate_context!()).expect(\"Failed to build Tauri application\")`. Tauri's `build` returns a `Result`; failure means the app could not be initialized (context/icon/window setup problems), and the panic aborts the desktop process.","triggerScenarios":"Invalid or missing Tauri configuration/resources referenced by `generate_context!`, failure to create the app or its state/plugins, a bad window builder configuration, or runtime setup (e.g. single-instance, notification plugin init) returning an error.","commonSituations":"Building with assets/config that differ between dev and production (the app intentionally avoids windows in tauri.conf.json), mismatched Tauri versions/features in Cargo.toml, missing icons/resources after `tauri.conf.json` edits, or running in environments lacking required system libraries (WebKitGTK on Linux).","solutions":["Read the panic message's inner Tauri error — it names the failing build step (config, window, plugin, or resource).","Verify tauri.conf.json, icons, and any referenced resources exist and are valid; re-run `cargo clean` and rebuild.","Check system dependencies for the platform (Linux: libwebkit2gtk, libgtk-3; see Tauri prerequisites).","Replace `.expect` with propagated error handling so startup failures surface as a dialog/log instead of a panic."],"exampleFix":"// before\n.build(tauri::generate_context!())\n.expect(\"Failed to build Tauri application\")\n.run(|_app, event| { ... });\n\n// after\nlet app = tauri::Builder::default()\n    ...\n    .build(tauri::generate_context!())\n    .map_err(|e| anyhow!(\"Failed to build Tauri application: {e}\"))?;\napp.run(|_app, event| { ... });","handlingStrategy":"try-catch","validationCode":"// validate config/resources before build\nfn tauri_preflight() -> Result<(), String> {\n    if !std::path::Path::new(\"tauri.conf.json\").exists() {\n        return Err(\"tauri.conf.json missing\".into());\n    }\n    #[cfg(target_os = \"linux\")]\n    if std::process::Command::new(\"pkg-config\").args([\"--exists\", \"webkit2gtk-4.1\"])\n        .status().map(|s| !s.success()).unwrap_or(true) {\n        return Err(\"WebKitGTK not installed\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// no expect: capture tauri::Error and surface it\nlet app = builder.build(tauri::generate_context!())\n    .map_err(|e| anyhow!(\"Failed to build Tauri application: {e}\"))?;\napp.run(|_app, event| { ... });","preventionTips":["Keep tauri.conf.json, icons and embedded resources valid across dev/prod configs","Install platform GUI prerequisites (WebKitGTK/GTK on Linux) before launching","Pin Tauri versions and features in Cargo.toml; rebuild after upgrades","Replace build-time expects with Result-returning setup so failures log instead of panicking"],"tags":["tauri","desktop","startup","gui"],"backgroundTag":"tauri-app-build-failed","analyzedSha":"acf2587e46be174c10200489c9a2d23a39a98aeb","analyzedAt":"2026-09-02T22:42:28.464Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}