{"record":{"id":"a6a8fd14c1249ca1","repo":"cjpais/Handy","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/lib.rs","lineNumber":1077,"sourceCode":"\n                #[cfg(target_os = \"macos\")]\n                {\n                    let settings = get_settings(window.app_handle());\n                    let tray_visible =\n                        settings.show_tray_icon && !window.app_handle().state::<CliArgs>().no_tray;\n                    if tray_visible {\n                        // Tray is available: hide the dock icon, app lives in the tray\n                        let res = window\n                            .app_handle()\n                            .set_activation_policy(tauri::ActivationPolicy::Accessory);\n                        if let Err(e) = res {\n                            log::error!(\"Failed to set activation policy: {}\", e);\n                        }\n                    }\n                    // No tray: keep the dock icon visible so the user can reopen\n                }\n            }\n            tauri::WindowEvent::ThemeChanged(theme) => {\n                log::info!(\"Theme changed to: {:?}\", theme);\n                // Re-apply the current tray state with the new theme's icon set\n                utils::refresh_tray_icon(window.app_handle());\n            }\n            _ => {}\n        })\n        .invoke_handler(invoke_handler)\n        .build(tauri::generate_context!())\n        .expect(\"error while building tauri application\");\n\n    // Must sit between build() and run(): see the doc comment.\n    #[cfg(target_os = \"macos\")]\n    apply_startup_activation_policy(&mut app, headless_mode);\n\n    app.run(|app, event| match &event {\n        #[cfg(target_os = \"macos\")]\n        tauri::RunEvent::Reopen { .. } => {\n            // Fired when the already-running bundle is launched again from","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/cjpais/Handy/blob/ba10ce1943ef34e93c09494027fc0b9ced2e8a44/src-tauri/src/lib.rs#L1059-L1095","documentation":"Panic when tauri::Builder::build(generate_context!()) returns Err. Build validates the compiled-in context from tauri.conf.json plus registered plugins and setup state — failures include missing/invalid configuration (window definitions, bundle identifier), missing frontend dist assets referenced by the context, missing icons/capabilities files, or plugin/state setup that fails validation (e.g. state double-managed, capabilities referencing unknown windows).","triggerScenarios":"Application launch (run()) whenever context validation or plugin setup fails: frontendDist assets absent, tauri.conf.json schema drift after a Tauri upgrade, deleted icons or capability files still referenced, or misconfigured window/capability wiring.","commonSituations":"Building/bundling without the frontend build output present; upgrading Tauri without migrating tauri.conf.json; deleting icons/ or capabilities/ after they were referenced; dev scripts running from the wrong working directory so relative resource paths resolve incorrectly.","solutions":["Run with RUST_BACKTRACE=1 — the underlying io::Error names the failing file/config; read it before changing anything","Rebuild through the documented pipeline: bun install, bun run build, then bun run tauri dev|build from the repo root so dist/ and resources exist","After a Tauri upgrade, run the migration steps for tauri.conf.json and re-verify icons and capabilities files exist","Validate that every capability file references existing windows and every configured asset path exists"],"exampleFix":"// before\n.build(tauri::generate_context!())\n.expect(\"error while building tauri application\")\n\n// after — surface the underlying cause instead of a bare message\n.build(tauri::generate_context!())\n.unwrap_or_else(|e| panic!(\"error while building tauri application: {e}\"))","handlingStrategy":"validation","validationCode":"# CI pre-flight: everything the generated context embeds must exist\ntest -d dist || (echo \"frontend dist missing\" && exit 1)\npython3 -m json.tool src-tauri/tauri.conf.json > /dev/null || exit 1\nls src-tauri/icons/* > /dev/null || exit 1\nls src-tauri/capabilities/* > /dev/null || exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build through the documented pipeline (bun run build before tauri build/dev) so dist/ exists","Add CI checks that fail the release when icons, capabilities, or config validation are missing/invalid","Pin the Tauri version and run its config migration immediately on upgrade instead of deferring"],"tags":["rust","tauri","startup","configuration","build-context"],"backgroundTag":"tauri-context-build-failed","analyzedSha":"ba10ce1943ef34e93c09494027fc0b9ced2e8a44","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}