{"record":{"id":"4d02b34c6271f15e","repo":"nextai-translator/nextai-translator","slug":"error-while-building-tauri-application","errorCode":null,"errorMessage":"error while building tauri application","messagePattern":"error while building tauri application","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/src/main.rs","lineNumber":577,"sourceCode":"                }\n            });\n            let handle = app_handle.clone();\n            PinnedFromWindowEvent::listen_any(app_handle, move |event| {\n                let pinned = event.payload.pinned();\n                ALWAYS_ON_TOP.store(*pinned, Ordering::Release);\n                tray::create_tray(&handle).unwrap();\n            });\n\n            let handle = app_handle.clone();\n            ConfigUpdatedEvent::listen_any(app_handle, move |_event| {\n                clear_config_cache();\n                tray::create_tray(&handle).unwrap();\n            });\n            Ok(())\n        })\n        .invoke_handler(invoke_handler)\n        .build(tauri::generate_context!())\n        .expect(\"error while building tauri application\");\n\n    #[cfg(target_os = \"macos\")]\n    {\n        let config = config::get_config_by_app(app.handle()).unwrap_or_default();\n        if config.hide_the_icon_in_the_dock.unwrap_or(true) {\n            app.set_activation_policy(tauri::ActivationPolicy::Accessory);\n        } else {\n            app.set_activation_policy(tauri::ActivationPolicy::Regular);\n        }\n    }\n\n    app.run(|app, event| match event {\n        tauri::RunEvent::Exit { .. } => {\n            let _ = app.track_event(\"app_exited\", None);\n            app.flush_events_blocking();\n        }\n        tauri::RunEvent::Ready => {\n            let _ = app.track_event(\"app_started\", None);","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/nextai-translator/nextai-translator/blob/f57537ee4ad8ec654cb726b9907bab7a1f82601d/src-tauri/src/main.rs#L559-L595","documentation":"The final .build(tauri::generate_context!()) in main is unwrapped with .expect(\"error while building tauri application\"), so any failure assembling the Tauri app (config parsing, plugin/tray setup errors propagated through setup, asset embedding) panics at startup. It is the catch-all fatal error for application boot.","triggerScenarios":"Invalid tauri.conf.json (schema/missing fields, missing icon files referenced by generate_context!), a setup hook returning Err (e.g. tray::create_tray failing), or plugin initialization errors.","commonSituations":"Renamed/removed icon files still referenced in config; malformed JSON or unsupported config keys after a Tauri major upgrade; tray creation failing on desktops without system tray support; bad plugin config.","solutions":["Read the wrapped cause printed with the panic — it names the failing config/setup step","Validate tauri.conf.json against the Tauri schema and confirm all icon paths exist","Check the setup() closure — tray::create_tray(&handle).unwrap() will poison the result; handle headless/trayless desktops","Pin/align tauri plugin versions with the core tauri version after upgrades"],"exampleFix":"// before\ntray::create_tray(&handle).unwrap();\n// after\nif let Err(e) = tray::create_tray(&handle) {\n    log::warn!(\"tray unavailable: {e}\"); // don't fail app build\n}","handlingStrategy":"try-catch","validationCode":"// shell, before launch:\npython3 -c \"import json; json.load(open('src-tauri/tauri.conf.json'))\" || exit 1\nfor icon in $(jq -r '.bundle.icon[]' src-tauri/tauri.conf.json 2>/dev/null); do test -f \"src-tauri/$icon\" || { echo \"missing icon $icon\"; exit 1; }; done","typeGuard":"// Rust: make setup hooks fail-safe\nfn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {\n    if let Err(e) = tray::create_tray(app.handle()) {\n        log::warn!(\"tray unavailable: {e}\"); // do not propagate\n    }\n    Ok(())\n}","tryCatchPattern":"let app = tauri::Builder::default()\n    .setup(|app| { if let Err(e) = tray::create_tray(app.handle()) { log::warn!(\"{e}\"); } Ok(()) })\n    .build(tauri::generate_context!());\nif let Err(e) = app {\n    eprintln!(\"failed to build tauri application: {e}\");\n    std::process::exit(1);\n}","preventionTips":["Validate tauri.conf.json against the schema in CI","Ensure all icons/fonts/resources referenced by config exist in the repo","Never .unwrap() inside setup hooks; log and degrade gracefully","Keep tauri and plugin versions aligned after upgrades; test a clean build"],"tags":["tauri","rust","startup","config"],"backgroundTag":"app-builder-failed","analyzedSha":"f57537ee4ad8ec654cb726b9907bab7a1f82601d","analyzedAt":"2026-08-31T11:24:08.384Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}