Repository: tauri-apps/tauri
Pull request #13426: fix(cli): slow dev startup
Author: login: Legend-Master
Created: 2025-05-13T09:32:25Z | Merged: 2025-05-14T08:48:05Z

<!--
Before submitting a PR, please read https://github.com/tauri-apps/tauri/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(windows): fix race condition in event loop
    - docs: update example for `App::show`
    - feat: add `Window::set_fullscreen`

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. If there is a related issue, reference it in the PR text, e.g. closes #123.
3. If this change requires a new version, then add a change file in `.changes` directory with the appropriate bump, see https://github.com/tauri-apps/tauri/blob/dev/.changes/README.md
4. Ensure that all your commits are signed https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
5. Ensure `cargo test` and `cargo clippy` passes.
6. Propose your changes as a draft PR if your work is still in progress.
-->

Noticed the CLI commands were quite slow to start, and they seem to use quite a lot of CPU as well, and it turned out it's polling on the file watcher results on `Cargo.toml`, what a scam 🤦‍♂️ 

Linked issue #7123: [bug] cargo tauri dev not working, code: 216
### Describe the bug

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 216, kind: Uncategorized, message: "This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher." }', C:\Users\xxx\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-cli-1.3.1\src\interface\rust\desktop.rs:57:63

### Reproduction

     npm create vite@latest example -- --template svelte
     cd example
     npx svelte-add

The options I choose for svelte-add are `JavaScript`, `PostCSS`, `Yes` to Autoprefixer, `Tailwind CSS`, `No` to forms plugin, `No` to typography plugin, `Yes` to daisyUI, no extra features, no code quality tools, `Nowhere` as a deployment target, `No` example code, and `Yes` to install dependencies.

From here I followed the [getting started guide](https://tauri.app/v1/guides/getting-started/setup/vite) up to `cargo tauri dev`, where I encountered the error.

### Expected behavior

Expected window to open

### Platform and versions

```text
[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.37
    ✔ MSVC:
        - Visual Studio Enterprise 2022
        - Visual Studio Build Tools 2022
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.16.0
    - npm: 9.6.7

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:5173/
    - framework: Svelte
    - bundler: Vite
```


### Stack trace

```text
stack backtrace:
   0:     0x7ff6182cd2c4 - <unknown>
   1:     0x7ff617d46ecb - <unknown>
   2:     0x7ff6182ab9e1 - <unknown>
   3:     0x7ff6182d1d0b - <unknown>
   4:     0x7ff6182d18e8 - <unknown>
   5:     0x7ff6182d14ca - <unknown>
   6:     0x7ff6182d23b6 - <unknown>
   7:     0x7ff6182d22b6 - <unknown>
   8:     0x7ff6182d2209 - <unknown>
   9:     0x7ff6182d21f4 - <unknown>
  10:     0x7ff618855a95 - <unknown>
  11:     0x7ff618855e66 - <unknown>
  12:     0x7ff6184b3765 - <unknown>
  13:     0x7ff6184b27cb - <unknown>
  14:     0x7ff6184d2ee6 - <unknown>
  15:     0x7ff6182c905c - <unknown>
  16:     0x7ffa4af126ad - BaseThreadInitThunk
  17:     0x7ffa4bbea9f8 - RtlUserThreadStart
```


### Additional context

I have all the [prerequisites from the website](https://tauri.app/v1/guides/getting-started/prerequisites/), I even tried adding a few to get things to work.

![image](https://github.com/tauri-apps/tauri/assets/30678712/730baed5-4d36-4fed-9e2e-6c1fa6012e3a)
![image](https://github.com/tauri-apps/tauri/assets/30678712/c2c77491-a075-4190-b09b-6836f574560b)

The output of `rustc --version` is `rustc 1.70.0 (90c541806 2023-05-31)`
Linked issue comments: user: login: FabianLars
created_at: 2023-06-04T12:11:36Z
body: Super confusing. Every time we saw this error so far was caused by the use of Visual Studio 2017 or below instead of 2019/2022.

Did you recently uninstall older versions of VS?

Also it could be that the terminal session only recognizes tools installed in your VS Enterprise installation and not the VS Build Tools one. So maybe the Enterprise installation has really old tools, or missing tools? Btw, you can install the Win11 SDK and MSVC v143 in the Enterprise installation and can remove the Build Tools installation again if you only installed it for Tauri.
author_association: MEMBER
user: login: atfox98
created_at: 2023-06-04T17:14:00Z
body: I did recently uninstall VS Enterprise 2017 to upgrade to 2022. To try to rule everything out, I completely uninstalled everything in the VS installer. After restarting the output of `cargo tauri info` was:

[✘] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.37
    ✘ Couldn't detect Visual Studio or Visual Studio Build Tools. Download from https://aka.ms/vs/17/release/vs_BuildTools.exe
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.16.0
    - npm: 9.6.7

I then installed just MSVC v143 and the Windows 10 SDK (10.0.19041.0, same one highlighted on the prereqs page).`cargo tauri info` came back with:

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.37
    ✔ MSVC: Visual Studio Enterprise 2022
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.16.0
    - npm: 9.6.7

Same error as before: thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 216, kind: Uncategorized, message: "This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher." }', C:\Users\Austin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-cli-1.3.1\src\interface\rust\desktop.rs:57:63

Any suggestions? What tools are being called? I can use `which` on the terminal to see if there are any other installations that are causing problems.
author_association: NONE
user: login: FabianLars
created_at: 2023-06-05T08:14:39Z
body: > What tools are being called?

The 216 comes from calling `cargo build` so i'm not sure what it or the webview related dependencies do tbh. (should be this one likely https://github.com/wravery/webview2-rs)

I'm honestly a bit out of ideas here, maybe try reinstalling/repairing the webview2 installation 😅 
author_association: MEMBER
user: login: atfox98
created_at: 2023-06-05T23:13:42Z
body: I tried making a project with `cargo create-tauri-app` and everything worked out fine. I think it might have been a problem with svelte-add, although I'm not 100% sure. Going ahead and closing. Thank you for your help
author_association: NONE

Diff:
diff --git a/.changes/cli-dev-slow-start.md b/.changes/cli-dev-slow-start.md
new file mode 100644
index 000000000000..259c951886c3
--- /dev/null
+++ b/.changes/cli-dev-slow-start.md
@@ -0,0 +1,5 @@
+---
+tauri-cli: "patch:bug"
+---
+
+Fix `dev`, `build` and `bundle` commands always take 2 seconds to start
diff --git a/crates/tauri-cli/src/interface/rust.rs b/crates/tauri-cli/src/interface/rust.rs
index 5706fe4247e4..507533ba61ee 100644
--- a/crates/tauri-cli/src/interface/rust.rs
+++ b/crates/tauri-cli/src/interface/rust.rs
@@ -5,13 +5,13 @@
 use std::{
   collections::HashMap,
   ffi::OsStr,
-  fs::{File, FileType},
-  io::{BufRead, Read, Write},
+  fs::FileType,
+  io::{BufRead, Write},
   path::{Path, PathBuf},
   process::Command,
   str::FromStr,
   sync::{mpsc::sync_channel, Arc, Mutex},
-  time::{Duration, Instant},
+  time::Duration,
 };
 
 use anyhow::Context;
@@ -126,22 +126,16 @@ impl Interface for Rust {
     let manifest = {
       let (tx, rx) = sync_channel(1);
       let mut watcher = new_debouncer(Duration::from_secs(1), None, move |r| {
-        if let Ok(events) = r {
-          let _ = tx.send(events);
+        if let Ok(_events) = r {
+          let _ = tx.send(());
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
-        }
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        // Wait for the modified event so we don't trigger a re-build later on
+        let _ = rx.recv_timeout(Duration::from_secs(2));
       }
       manifest
     };
@@ -409,12 +403,10 @@ fn dev_options(
 
 // Copied from https://github.com/rust-lang/cargo/blob/69255bb10de7f74511b5cef900a9d102247b6029/src/cargo/core/workspace.rs#L665
 fn expand_member_path(path: &Path) -> crate::Result<Vec<PathBuf>> {
-  let Some(path) = path.to_str() else {
-    return Err(anyhow::anyhow!("path is not UTF-8 compatible"));
-  };
-  let res = glob(path).with_context(|| format!("could not parse pattern `{}`", &path))?;
+  let path = path.to_str().context("path is not UTF-8 compatible")?;
+  let res = glob(path).with_context(|| format!("could not parse pattern `{path}`"))?;
   let res = res
-    .map(|p| p.with_context(|| format!("unable to match path to pattern `{}`", &path)))
+    .map(|p| p.with_context(|| format!("unable to match path to pattern `{path}`")))
     .collect::<Result<Vec<_>, _>>()?;
   Ok(res)
 }
@@ -614,8 +606,7 @@ impl<T> MaybeWorkspace<T> {
         ))
       }
       MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: false }) => Err(anyhow::anyhow!(
-        "`workspace=false` is unsupported for `package.{}`",
-        label,
+        "`workspace=false` is unsupported for `package.{label}`"
       )),
     }
   }
@@ -694,12 +685,9 @@ impl CargoSettings {
   /// Try to load a set of CargoSettings from a "Cargo.toml" file in the specified directory.
   fn load(dir: &Path) -> crate::Result<Self> {
     let toml_path = dir.join("Cargo.toml");
-    let mut toml_str = String::new();
-    let mut toml_file = File::open(toml_path).with_context(|| "failed to open Cargo.toml")?;
-    toml_file
-      .read_to_string(&mut toml_str)
-      .with_context(|| "failed to read Cargo.toml")?;
-    toml::from_str(&toml_str).with_context(|| "failed to parse Cargo.toml")
+    let toml_str = std::fs::read_to_string(&toml_path)
+      .with_context(|| format!("Failed to read {}", toml_path.display()))?;
+    toml::from_str(&toml_str).with_context(|| format!("Failed to parse {}", toml_path.display()))
   }
 }
 
@@ -976,10 +964,10 @@ impl AppSettings for RustAppSettings {
       .unwrap()
       .inner
       .as_table()
-      .get("package")
-      .and_then(|p| p.as_table())
-      .and_then(|p| p.get("name"))
-      .and_then(|n| n.as_str())
+      .get("package")?
+      .as_table()?
+      .get("name")?
+      .as_str()
       .map(|n| n.to_string())
   }
 
@@ -990,10 +978,10 @@ impl AppSettings for RustAppSettings {
       .unwrap()
       .inner
       .as_table()
-      .get("lib")
-      .and_then(|p| p.as_table())
-      .and_then(|p| p.get("name"))
-      .and_then(|n| n.as_str())
+      .get("lib")?
+      .as_table()?
+      .get("name")?
+      .as_str()
       .map(|n| n.to_string())
   }
 }
@@ -1001,8 +989,7 @@ impl AppSettings for RustAppSettings {
 impl RustAppSettings {
   pub fn new(config: &Config, manifest: Manifest, target: Option<String>) -> crate::Result<Self> {
     let tauri_dir = tauri_dir();
-    let cargo_settings =
-      CargoSettings::load(tauri_dir).with_context(|| "failed to load cargo settings")?;
+    let cargo_settings = CargoSettings::load(tauri_dir).context("failed to load cargo settings")?;
     let cargo_package_settings = match &cargo_settings.package {
       Some(package_info) => package_info.clone(),
       None => {
@@ -1013,7 +1000,7 @@ impl RustAppSettings {
     };
 
     let ws_package_settings = CargoSettings::load(&get_workspace_dir()?)
-      .with_context(|| "failed to load cargo settings from workspace root")?
+      .context("failed to load cargo settings from workspace root")?
       .workspace
       .and_then(|v| v.package);
 
@@ -1194,7 +1181,7 @@ fn get_cargo_option<'a>(args: &'a [String], option: &'a str) -> Option<&'a str>
 pub fn get_workspace_dir() -> crate::Result<PathBuf> {
   Ok(
     get_cargo_metadata()
-      .with_context(|| "failed to get cargo metadata")?
+      .context("failed to get cargo metadata")?
       .workspace_root,
   )
 }
diff --git a/crates/tauri-cli/src/interface/rust/manifest.rs b/crates/tauri-cli/src/interface/rust/manifest.rs
index 055e84cbbeb6..f4d51a440bbd 100644
--- a/crates/tauri-cli/src/interface/rust/manifest.rs
+++ b/crates/tauri-cli/src/interface/rust/manifest.rs
@@ -14,7 +14,7 @@ use toml_edit::{Array, DocumentMut, InlineTable, Item, TableLike, Value};
 use std::{
   collections::{HashMap, HashSet},
   fs::File,
-  io::{Read, Write},
+  io::Write,
   path::Path,
 };
 
@@ -83,15 +83,12 @@ fn get_enabled_features(list: &HashMap<String, Vec<String>>, feature: &str) -> V
 }
 
 pub fn read_manifest(manifest_path: &Path) -> crate::Result<(DocumentMut, String)> {
-  let mut manifest_str = String::new();
-
-  let mut manifest_file = File::open(manifest_path)
-    .with_context(|| format!("failed to open `{manifest_path:?}` file"))?;
-  manifest_file.read_to_string(&mut manifest_str)?;
+  let manifest_str = std::fs::read_to_string(manifest_path)
+    .with_context(|| format!("Failed to read `{manifest_path:?}` file"))?;
 
   let manifest: DocumentMut = manifest_str
     .parse::<DocumentMut>()
-    .with_context(|| "failed to parse Cargo.toml")?;
+    .with_context(|| "Failed to parse Cargo.toml")?;
 
   Ok((manifest, manifest_str))
 }


Reviews:
user: login: Legend-Master
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-13T09:34:03Z
user: login: FabianLars
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-13T17:52:26Z
user: login: Legend-Master
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T01:39:30Z
user: login: FabianLars
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T08:21:42Z
user: login: FabianLars
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T08:24:35Z
user: login: Legend-Master
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T08:29:37Z
user: login: FabianLars
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T08:44:37Z
user: login: FabianLars
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-14T08:45:04Z

Review comments:
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: Legend-Master
body: This is the changed part, other parts are just some small refactors that I did when looking through them

Also, I'm not entirely sure what does this watch even do, I would assume it's for waiting for the file modification to take effect from `rewrite_manifest`, is it?
created_at: 2025-05-13T09:34:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: FabianLars
body: looks like it yeah. just so that it doesn't trigger a rebuild ig
created_at: 2025-05-13T17:52:26Z
author_association: MEMBER
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: Legend-Master
body: Added some comments and changed the loop to `recv_timeout`
created_at: 2025-05-14T01:39:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -126,22 +126,16 @@ impl Interface for Rust {
     let manifest = {
       let (tx, rx) = sync_channel(1);
       let mut watcher = new_debouncer(Duration::from_secs(1), None, move |r| {
-        if let Ok(events) = r {
-          let _ = tx.send(events);
+        if let Ok(_events) = r {
+          let _ = tx.send(());
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
-        }
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        // Wait for the modified event so we don't trigger a re-build laster on
path: crates/tauri-cli/src/interface/rust.rs
user: login: FabianLars
body: ```suggestion
        // Wait for the modified event so we don't trigger a re-build later on
```
created_at: 2025-05-14T08:21:42Z
author_association: MEMBER
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: FabianLars
body: Should we maybe reduce the timeout then? I find it hard to believe that it could take up to 2 seconds 🤔 Or maybe, better safe than sorry idk
created_at: 2025-05-14T08:24:34Z
author_association: MEMBER
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: Legend-Master
body: Whatever I guess, the timeout is just there to make sure we move on, if there's indeed an modification and no errors, the watcher should tell us before the timeout, I'm not sure what time to set for the denouncer though, 1 sec feels too long to me, but I don't really care since it's rare, better safe then sorry I guess 🙃
created_at: 2025-05-14T08:29:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -131,16 +131,18 @@ impl Interface for Rust {
         }
       })
       .unwrap();
-      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::Recursive)?;
-      let (manifest, _modified) = rewrite_manifest(config)?;
-      let now = Instant::now();
-      let timeout = Duration::from_secs(2);
-      loop {
-        if now.elapsed() >= timeout {
-          break;
-        }
-        if rx.try_recv().is_ok() {
-          break;
+      watcher.watch(tauri_dir().join("Cargo.toml"), RecursiveMode::NonRecursive)?;
+      let (manifest, modified) = rewrite_manifest(config)?;
+      if modified {
+        let now = Instant::now();
+        let timeout = Duration::from_secs(2);
+        loop {
+          if now.elapsed() >= timeout {
+            break;
+          }
+          if rx.try_recv().is_ok() {
+            break;
+          }
         }
       }
path: crates/tauri-cli/src/interface/rust.rs
user: login: FabianLars
body: Your call 🤷
created_at: 2025-05-14T08:44:37Z
author_association: MEMBER

PR comments:
user: login: github-actions[bot]
created_at: 2025-05-13T09:32:47Z
body: <!-- Covector Action -->
<!-- Covector Action -->
### Package Changes Through 5fa4cad7ec1c5e7c880bf66af78343cc0145df3a
There are 7 changes which include tauri-bundler with patch, tauri with minor, tauri-cli with patch, @tauri-apps/api with minor, tauri-utils with minor, @tauri-apps/cli with patch, tauri-runtime-wry with patch

<details>
<summary><i>Planned Package Versions</i></summary>

The following package releases are the planned based on the context of changes in this pull request.
| package | current | next |
  |----|----|----|
| @tauri-apps/api | 2.5.0 | 2.6.0 |
 tauri-utils | 2.4.0 | 2.5.0 |
 tauri-bundler | 2.4.0 | 2.4.1 |
 tauri-runtime | 2.6.0 | 2.6.1 |
 tauri-runtime-wry | 2.6.0 | 2.6.1 |
 tauri-codegen | 2.2.0 | 2.2.1 |
 tauri-macros | 2.2.0 | 2.2.1 |
 tauri-plugin | 2.2.0 | 2.2.1 |
 tauri-build | 2.2.0 | 2.2.1 |
 tauri | 2.5.1 | 2.6.0 |
 @tauri-apps/cli | 2.5.0 | 2.5.1 |
 tauri-cli | 2.5.0 | 2.5.1 |

</details>

[Add another change file through the GitHub UI by following this link.](https://github.com/Legend-Master/tauri/new/cli-dev-slow-startup?filename=.changes/change-pr-13426.md&value=---%0A%22@tauri-apps/api%22:%20patch%0A%22tauri-utils%22:%20patch%0A%22tauri-macos-sign%22:%20patch%0A%22tauri-bundler%22:%20patch%0A%22tauri-runtime%22:%20patch%0A%22tauri-runtime-wry%22:%20patch%0A%22tauri-codegen%22:%20patch%0A%22tauri-macros%22:%20patch%0A%22tauri-plugin%22:%20patch%0A%22tauri-build%22:%20patch%0A%22tauri%22:%20patch%0A%22@tauri-apps/cli%22:%20patch%0A%22tauri-cli%22:%20patch%0A%22tauri-driver%22:%20patch%0A---%0A%0Afix(cli):%20slow%20dev%20startup%0A)


---
<p align='right'><em>Read about <a href='../tree/HEAD/.changes'>change files</a><em> or the docs at <a href='https://github.com/jbolda/covector/tree/main/packages/covector'>github.com/jbolda/covector</a><em></p>
author_association: CONTRIBUTOR
user: login: FabianLars
created_at: 2025-05-13T11:36:49Z
body: loooool that's the actual "add sleep 2 secs so we can improve perf later" meme 🤣🤣🤣
author_association: MEMBER