New: outcomized services. Pay per result, with a monthly cap you set. See pricing →
Engineering

Tauri v2 and Rust: The Compile Errors AI Agents Keep Making

Updated 2026-10 · 9 min read · By the Founder of Outcomizer, former CTO and co-founder

We build desktop tools in Tauri v2 with a Rust backend, and most of that code is written by agents. They are good at it, with one stubborn flaw: their training data is full of Tauri v1, and they make the same Rust mistakes over and over. Each one is a two-minute fix. Twenty of them per session is an afternoon gone.

So we wrote the mistakes down. Two rule files, one for Tauri v2 and one for Rust compile errors, now load automatically whenever an agent touches a Tauri project. This is what is in them and why. Code is described in words here, with names in backticks.

Want this built, not just scoped?A live AI MVP on your domain in 15 days for $4,500. Then $1,500 a week sprints.

The v1 ghost: APIs that no longer exist

The most common error is the agent reaching for `tauri::api::path::app_data_dir`. The whole `tauri::api` module was removed in v2. Path helpers now live on the app handle: you call `app_handle.path().app_data_dir()`, which needs the `tauri::Manager` trait in scope, and inside a command you get the handle by adding a `tauri::AppHandle` parameter. In the setup closure you get it from `app.handle()`.

The same ghost shows up on the frontend. Agents import `invoke` from `@tauri-apps/api/tauri`, which was the v1 path. In v2 it is `@tauri-apps/api/core`. And in `tauri.conf.json` they put `identifier` inside the `bundle` block, which is also v1. In v2 it sits at the root.

None of these are hard. They are just confidently wrong, and an agent will sometimes "fix" the compile error by inventing a third API that also does not exist. Our rule file names each removed API next to its v2 replacement, so the agent never has to guess.

Two crates, one folder: the AppState trap

A Tauri v2 project usually has both `main.rs` and `lib.rs`. Agents treat `main` as a module and write `crate::main::AppState` from library code. That cannot compile: `main.rs` is the root of the binary crate and `lib.rs` is the root of a separate library crate. Library code cannot see into the binary.

The rule is simple. Shared types such as `AppState` live in `lib.rs`. Modules under the library import them as `crate::AppState`. The binary imports them from the library by its crate name, the one set in the `[lib]` section of `Cargo.toml`.

Related: state must be registered with `.manage()` before any command can receive it as `State<'_, AppState>`. If an agent adds a new piece of state and a new command in the same change, we ask it to show where the state is managed.

Commands, derives, and serialization

Every Tauri command in our projects returns `Result<T, String>` where `T` is serializable. Any struct returned from a command needs `Serialize`. Any struct received as a command argument needs `Deserialize`. The one agents miss is the nested case: if `SyncReport` derives both and contains a `Vec<DeployResult>`, then `DeployResult` needs both too, or the outer derive fails with an error that points at the wrong struct.

Our checklist runs per struct: returned from a command, add `Serialize`; used as an argument, add `Deserialize`; nested in either, add both; cloned anywhere, add `Clone`; printed with debug formatting, add `Debug`. It is boring, and it removes a whole class of compile loops.

If you are planning a desktop MVP on Tauri and want it built by agents running this exact rule set, that is a normal 15-day build for us.

Want this built, not just scoped?

A live AI MVP on your domain in 15 days for $4,500. Then $1,500 a week sprints.

See the 15-day AI MVP

The Rust inference errors that repeat

A handful of compiler errors make up most of the noise. When `.map_err(|e| e.to_string())` fails with "type annotations needed", annotate the closure parameter with the concrete error type: `PoisonError` for a mutex lock, `rusqlite::Error` for the database, your own `thiserror` enum for custom errors. When `confidence.min(1.0)` fails because the compiler cannot pick a float type, type the literal as `0.85_f32` or annotate the binding.

Async HTTP is the other repeat offender. With `reqwest`, the `.text()`, `.json()`, and `.bytes()` methods are all async, so you cannot feed them into `.and_then()` after `send().await`. Await the send, handle its error, then await the body and handle that error separately. The second form also gives you better error messages, because you can tell a failed request from a failed body read.

Smaller ones: `Url::path_segments()` returns an `Option` of a split iterator that has no `Default`, so `unwrap_or_default()` does not compile on it. Match on the option, or map to a collected `Vec` first. A borrowed fallback like `unwrap_or(&vec![])` can trip "temporary value dropped while borrowed", so bind the empty vector to a variable first.

State you cannot clone

Agents like to call one command from another, for example a "deploy all" command looping over items and calling the "deploy one" command with `state.clone()`. `tauri::State` borrows from the runtime and is not meant to be passed around like that. The fix is structural: lock the inner data once, then run the shared logic as a plain function over that data. Commands become thin wrappers over ordinary Rust functions, which is also easier to test.

This is the one rule that improves design, not just compilation. Once commands are thin, the logic underneath can be unit tested without a Tauri runtime at all.

How we wire the rule files into the agent

Both files are skills that trigger on words like tauri, cargo build, or compile error, so they load without anyone remembering to paste them. Each ends with a pre-commit checklist the agent runs before building: no `tauri::api` calls, no `crate::main` references, all command types derive the right traits, all reqwest body reads awaited, floats typed where inference fails, no recursive commands passing state.

We also tell the agent to run `cargo check` before `cargo build`. It is faster feedback and keeps the loop tight. The general lesson travels beyond Rust: when an agent makes the same mistake twice, the fix is not a better prompt next time. It is a rule file that loads every time.

Key takeaways

  • Agents default to Tauri v1. Name every removed API next to its v2 replacement in a rule file.
  • Put shared types like AppState in lib.rs. The binary and library are separate crates.
  • Derive Serialize and Deserialize on nested structs too, not just the outer one.
  • Annotate closure error types and float literals when inference fails instead of letting the agent guess.
  • When an agent repeats a mistake, write a rule that loads automatically. Do not rely on remembering.

Frequently asked questions

Most public examples, tutorials, and answers were written for v1, so that is what the models learned. Without explicit v2 rules in context they reach for the more familiar API.

If you want a small binary and are comfortable with a Rust backend, Tauri v2 works well with agents once the rule files are in place. If your team only knows JavaScript and needs Node APIs everywhere, Electron is the more boring choice, and boring is fine.

No. They remove the repeat mistakes, which are most of the noise. Real design problems, such as ownership across async boundaries, still need an engineer to read the code.

Free playbook

The 15-Day AI MVP Playbook

Day-by-day plan, a starter CLAUDE.md, the Lovable-to-production checklist, eval and cost worksheets, and 10 prompts. Pure value, no pitch.

Get the playbook →
Next step

Book 20 minutes, or send a brief

A former CTO replies. You leave with a written plan and a fixed estimate.

No spam. One reply within one business day. Or skip the form and book a call.

Thank you. Your brief is on its way. Grab a time now so we can talk it through.

Prefer LinkedIn? Connect with Harish.

HG
Harish Ganapathi, Founder of Outcomizer, former CTO and co-founder

I started Outcomizer because hourly billing rewards the wrong thing. As a CTO I led an 18-engineer team and shipped the products in these case studies, including a Fortune 100 shipping system and a SaaS we later sold. Now I put my fee on the result. I still do the work. You work with me, not a sales layer on top of a bench.

Connect on LinkedIn →
Book a callFree lead test