<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yuexun Jiang</title>
    <description>The latest articles on DEV Community by Yuexun Jiang (@ahonn).</description>
    <link>https://dev.to/ahonn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F377874%2Fcb7f12f6-3e46-47f1-997b-f0e37186ee5c.png</url>
      <title>DEV Community: Yuexun Jiang</title>
      <link>https://dev.to/ahonn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahonn"/>
    <language>en</language>
    <item>
      <title>How to make your Tauri dev faster</title>
      <dc:creator>Yuexun Jiang</dc:creator>
      <pubDate>Thu, 01 May 2025 22:42:31 +0000</pubDate>
      <link>https://dev.to/ahonn/how-to-make-your-tauri-dev-faster-2en1</link>
      <guid>https://dev.to/ahonn/how-to-make-your-tauri-dev-faster-2en1</guid>
      <description>&lt;p&gt;Tauri lets us build cross-platform desktop apps using web stack.&lt;br&gt;
Compared to Electron, Tauri apps often have smaller bundle sizes and use less memory at runtime.&lt;br&gt;
That's why I usually pick Tauri for my desktop projects.&lt;/p&gt;

&lt;p&gt;However, during development, especially after changing the Rust code, the &lt;code&gt;tauri dev&lt;/code&gt; command can sometimes take a really long time to compile.&lt;br&gt;
It might even recompile many dependencies every single time you make a change, which seriously slows down development.&lt;/p&gt;

&lt;p&gt;This post shares some tips and tricks I found while trying to speed up the development compile times for my app.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Is It So Slow?
&lt;/h2&gt;

&lt;p&gt;First things first: why does &lt;code&gt;tauri dev&lt;/code&gt; take so long?&lt;br&gt;
If you look at the command's output, you might notice it recompiles a bunch of unchanged dependencies every time you modify your Rust code.&lt;/p&gt;

&lt;p&gt;After some digging, I found the reason: Tauri uses the &lt;code&gt;bundle.macos.minimumSystemVersion&lt;/code&gt; setting from your &lt;code&gt;tauri.config.json&lt;/code&gt; as the value for the &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt; environment variable during its build process.&lt;br&gt;
If you haven't set it, it defaults to &lt;code&gt;10.13&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you save changes in your editor, &lt;code&gt;rust-analyzer&lt;/code&gt; often runs &lt;code&gt;cargo check&lt;/code&gt; to look for errors. But, it usually runs without &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt; being set.&lt;br&gt;
This difference in environment variables between &lt;code&gt;rust-analyzer&lt;/code&gt;'s check and the actual &lt;code&gt;tauri dev&lt;/code&gt; build forces some dependencies to be recompiled twice – once by &lt;code&gt;rust-analyzer&lt;/code&gt; and then again by &lt;code&gt;tauri dev&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For my app, a simple code change initially meant waiting about a minute for the compile to finish.&lt;br&gt;
So, how do we fix this? We need to make sure both &lt;code&gt;rust-analyzer&lt;/code&gt; and Tauri use the &lt;em&gt;same&lt;/em&gt; value for &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add this to your editor's settings (e.g., VS Code's &lt;code&gt;settings.json&lt;/code&gt;.):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rust-analyzer.cargo.extraEnv"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"MACOSX_DEPLOYMENT_TARGET"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10.13"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add this to your &lt;code&gt;tauri.config.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"bundle"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"macos"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"minimumSystemVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10.13"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the version string (&lt;code&gt;"10.13"&lt;/code&gt; in this case) matches in both places. After saving these changes, restart your editor and the &lt;code&gt;tauri dev&lt;/code&gt; process.&lt;br&gt;
Now, try changing your Rust code again. You should see a noticeable improvement. My one-minute compile time dropped to around 25 seconds.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;rust-analyzer&lt;/code&gt; Still Causing Issues?
&lt;/h2&gt;

&lt;p&gt;Even after fixing the environment variable mismatch, you might still hit frustrating delays. Sometimes, you'll see &lt;code&gt;tauri dev&lt;/code&gt; stuck on a message like &lt;code&gt;Blocking waiting for file lock on build directory&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What's happening here? &lt;code&gt;rust-analyzer&lt;/code&gt; runs &lt;code&gt;cargo check&lt;/code&gt; in the background to give you live feedback. Both this background check and your manual &lt;code&gt;tauri dev&lt;/code&gt; command need to access and modify files in your project's &lt;code&gt;target&lt;/code&gt; directory.&lt;br&gt;
When they try to do this at the same time, one has to wait for the other to release the "lock", causing your build to pause.&lt;/p&gt;

&lt;p&gt;Fortunately, &lt;code&gt;rust-analyzer&lt;/code&gt; has a setting to fix this: you can tell it to put its build files in a separate directory, avoiding conflicts with &lt;code&gt;tauri dev&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add this to your editor's settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rust-analyzer.cargo.targetDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"target/analyzer"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Alternatively&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;setting&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;it&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;uses&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'target/rust-analyzer'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;default&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rust-analyzer.cargo.targetDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells &lt;code&gt;rust-analyzer&lt;/code&gt; to put its temporary build artifacts in the &lt;code&gt;target/analyzer&lt;/code&gt; subdirectory.&lt;/p&gt;

&lt;p&gt;With this change, &lt;code&gt;rust-analyzer&lt;/code&gt;'s background checks won't block &lt;code&gt;tauri dev&lt;/code&gt; anymore.&lt;br&gt;
The trade-off is that you'll use a bit more disk space for this extra build cache, but the boost in development speed is usually well worth it.&lt;/p&gt;

&lt;p&gt;Try changing Rust code one more time, &lt;code&gt;tauri dev&lt;/code&gt; start compiling almost instantly. The total compile time should drop further, maybe down to 15-20 seconds.&lt;/p&gt;

&lt;p&gt;Setting &lt;code&gt;targetDir&lt;/code&gt; actually solves the original environment variable problem too!&lt;br&gt;
Because &lt;code&gt;rust-analyzer&lt;/code&gt; now uses a completely separate build cache, its environment doesn't interfere with &lt;code&gt;tauri dev&lt;/code&gt;'s environment.&lt;br&gt;
This is why I recommend using the &lt;code&gt;targetDir&lt;/code&gt; setting over manually setting &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt;, it solves both problems with one configuration change.&lt;/p&gt;
&lt;h2&gt;
  
  
  Tweaking Cargo Profiles
&lt;/h2&gt;

&lt;p&gt;We've tackled the environment conflicts and file lock issues, significantly speeding things up.&lt;br&gt;
Can we go even faster? Yes! Let's look at Cargo's build profiles, specifically the development profile (&lt;code&gt;profile.dev&lt;/code&gt;), to squeeze out a few more seconds.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;profile.dev&lt;/code&gt; section in your &lt;code&gt;src-tauri/Cargo.toml&lt;/code&gt; controls how &lt;code&gt;cargo build&lt;/code&gt; (and thus &lt;code&gt;tauri dev&lt;/code&gt; by default) behaves during development. Key settings include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;opt-level&lt;/code&gt;: How much optimization the compiler applies. Default is &lt;code&gt;0&lt;/code&gt; for fastest compiles.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;debug&lt;/code&gt;: How much debugging information is included. Default is &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;incremental&lt;/code&gt;: Whether to use incremental compilation (only recompile changed parts). Default is &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Incremental compilation (&lt;code&gt;incremental = true&lt;/code&gt;) is crucial for fast rebuilds, so we usually want to keep that enabled.&lt;/p&gt;

&lt;p&gt;However, we can often speed things up by slightly changing the settings for dependencies.&lt;br&gt;
We rarely debug directly into third-party library code, so we might not need full debug info for them.&lt;br&gt;
Sometimes, applying a small amount of optimization to dependencies can even make the final linking step faster.&lt;/p&gt;

&lt;p&gt;You can add or modify the &lt;code&gt;[profile.dev]&lt;/code&gt; and &lt;code&gt;[profile.dev.package."*"]&lt;/code&gt; sections in your &lt;code&gt;src-tauri/Cargo.toml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c"&gt;# src-tauri/Cargo.toml&lt;/span&gt;

&lt;span class="c"&gt;# ...&lt;/span&gt;

&lt;span class="nn"&gt;[profile.dev]&lt;/span&gt;
&lt;span class="py"&gt;incremental&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="py"&gt;opt-level&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="py"&gt;debug&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="nn"&gt;[profile.dev.package."*"]&lt;/span&gt;
&lt;span class="py"&gt;opt-level&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="py"&gt;debug&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changing profiles involves trade-offs. Less debug info makes debugging harder. Optimizing dependencies might hide bugs that only appear at &lt;code&gt;opt-level = 0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;first&lt;/em&gt; compile after changing these settings will likely be slow as Cargo rebuilds things. Judge the improvement based on subsequent incremental builds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After applying this, my compile times settled into the 10-15 second range.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;By making a few adjustments, we can significantly cut down on frustratingly long Tauri development compile times:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Configure &lt;code&gt;rust-analyzer.cargo.targetDir&lt;/code&gt;:&lt;/strong&gt; This is the most crucial and recommended step. Giving &lt;code&gt;rust-analyzer&lt;/code&gt; its own build directory solves file lock conflicts with &lt;code&gt;tauri dev&lt;/code&gt; and indirectly fixes environment variable mismatches (like &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt;). It provides the biggest speed boost with minimal downsides.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Adjust &lt;code&gt;[profile.dev.package."*"]&lt;/code&gt;:&lt;/strong&gt; After fixing the main bottlenecks, you can potentially gain a little more speed by applying slight optimizations and disabling debug info for your dependencies in &lt;code&gt;Cargo.toml&lt;/code&gt;. This is more of a fine-tuning step and requires testing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these optimizations, the compile time for an app dropped from over a minute to just 10-15 seconds. While using a separate &lt;code&gt;targetDir&lt;/code&gt; consumes extra disk space, the time saved makes it a worthwhile trade-off.&lt;/p&gt;

&lt;p&gt;Hopefully, these tips, gathered from troubleshooting real problems and exploring community solutions, will help you escape slow &lt;code&gt;tauri dev&lt;/code&gt; builds and let you focus more on building great Tauri app!&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tauri-apps/tauri/issues/8920" rel="noopener noreferrer"&gt;tauri dev is incredibly slow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rust-lang/rust-analyzer/issues/4616" rel="noopener noreferrer"&gt;Rust analyzer "cargo check" blocks debug builds&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tauri-apps/tauri/issues/11577" rel="noopener noreferrer"&gt;Tauri unilaterally overrides MACOSX_DEPLOYMENT_TARGET, causes sys crates to spuriously rebuild&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/rust-lang/rust-analyzer/issues/6007" rel="noopener noreferrer"&gt;Option to use rust-analyzer-specific target directory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles" rel="noopener noreferrer"&gt;Profiles - The Cargo Book&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>tauri</category>
    </item>
  </channel>
</rss>
