{"record":{"id":"a8d4a9dd609411fc","repo":"gitbutlerapp/gitbutler","slug":"failed-to-build-tauri-app","errorCode":null,"errorMessage":"Failed to build tauri app","messagePattern":"Failed to build tauri app","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/gitbutler-tauri/src/main.rs","lineNumber":421,"sourceCode":"                        .state::<WindowState>()\n                        .remove(window.label());\n                }\n                tauri::WindowEvent::Focused(focused) if *focused => {\n                    window\n                        .app_handle()\n                        .state::<WindowState>()\n                        .flush(window.label())\n                        .ok();\n                }\n                _ => {}\n            });\n\n        #[cfg(not(target_os = \"linux\"))]\n        let builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());\n\n        builder\n            .build(tauri_context)\n            .expect(\"Failed to build tauri app\")\n            .run(|_app_handle, _event| {});\n    });\n    Ok(())\n}\n\n/// read all objects, migrate them, and write them back if there was a migration.\nfn migrate_projects() -> anyhow::Result<()> {\n    for mut project in gitbutler_project::dangerously_list_projects_without_migration()? {\n        if let Ok(true) = project.migrate() {\n            let (title, git_dir) = (project.title.clone(), project.git_dir().to_owned());\n            if let Err(err) = gitbutler_project::update(project.into()) {\n                tracing::warn!(\n                    \"Failed to store migrated project {} at {}: {err}\",\n                    title,\n                    git_dir.display()\n                );\n            } else {\n                tracing::info!(\"Migrated project {} at {}\", title, git_dir.display());","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/gitbutler-tauri/src/main.rs#L403-L439","documentation":"`tauri::Builder::build(tauri_context)` assembles the app instance from the compile-time-generated context (tauri.conf.json, bundled assets, plugins) plus every registered plugin's setup. It returns Err when the context is inconsistent with the runtime environment, required assets are missing, or a plugin fails during initialization (for example tauri_plugin_window_state choking on a corrupt state file on non-Linux). The `.expect` aborts process startup, printing the underlying error to stderr.","triggerScenarios":"Executing `builder.build(tauri_context).expect(...)` at crates/gitbutler-tauri/src/main.rs:421 when the generated context is stale relative to tauri.conf.json, a configured asset is absent from the bundle, or a registered plugin's initialization returns an error.","commonSituations":"Stale build artifacts after pulling changes that edit tauri.conf.json; building with plain `cargo build` instead of the tauri CLI so context and assets do not match; version skew between tauri crates and the tauri-cli; a corrupt window-state cache.","solutions":["Read the stderr panic message first — it names the exact underlying cause","Clean rebuild through the tauri CLI (cargo clean, then cargo tauri dev or cargo tauri build) so context and config regenerate together","Delete a corrupt window-state file in the app-data dir if that plugin is implicated","Align tauri and tauri-plugin-* versions in Cargo.toml with the CLI that generated the context"],"exampleFix":"// before\nbuilder\n    .build(tauri_context)\n    .expect(\"Failed to build tauri app\")\n    .run(|_app_handle, _event| {});\n\n// after (main returns anyhow::Result)\nlet app = builder\n    .build(tauri_context)\n    .context(\"Failed to build tauri app\")?;\napp.run(|_app_handle, _event| {});","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"match builder.build(tauri_context) {\n    Ok(app) => app.run(|_, _| {}),\n    Err(e) => {\n        eprintln!(\"failed to build tauri app: {e}\");\n        std::process::exit(1);\n    }\n}","preventionTips":["Always generate release builds through the tauri CLI, never bare cargo build","Clean after editing tauri.conf.json or asset paths","Keep tauri crate versions locked in step with the CLI","Ship stderr/log capture so users can report the underlying error"],"tags":["rust","tauri","startup","build","panic"],"backgroundTag":"app-startup-failed","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}