Repository: tauri-apps/tauri (language: rust)

Issue:
[bug] unable to use 2024 edition because tauri-build reads Cargo.toml with old cargo_toml crate
### Describe the bug

unable to use 2024 edition

```
error: failed to run custom build command for `app v0.1.0 (/Users/anatawa12/tauri-2024/src-tauri)`

Caused by:
  process didn't exit successfully: `/Users/anatawa12/tauri-2024/src-tauri/target/release/build/app-2cd9b7cd989b4b2b/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=desktop
  TOML parse error at line 11, column 11
     |
  11 | edition = "2024"
     |           ^^^^^^
  data did not match any variant of untagged enum Inheritable
  : TOML parse error at line 11, column 11
     |
  11 | edition = "2024"
     |           ^^^^^^
  data did not match any variant of untagged enum Inheritable

warning: build failed, waiting for other jobs to finish...
       Error failed to build app: failed to build app
```

### Reproduction

Create project with tauri cli and bump to 2024 edition

### Expected behavior

it should work

### Full `tauri info` output

```text
[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.81.0-beta.2 (08328a323 2024-07-25)
    ✔ cargo: 1.81.0-beta.2 (a2b58c3da 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: beta-aarch64-apple-darwin (default)
    - node: 20.12.2
    - pnpm: 8.15.4
    - yarn: 1.22.19
    - npm: 10.8.1

[-] Packages
    - tauri [RUST]: 1.7.1 (no lockfile)
    - tauri-build [RUST]: no manifest (no lockfile)
    - wry [RUST]: no manifest (no lockfile)
    - tao [RUST]: no manifest (no lockfile)
    - tauri-cli [RUST]: 1.5.14
    - @tauri-apps/api [NPM]: 1.6.0
    - @tauri-apps/cli [NPM]: 1.6.0

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: out
    - devPath: http://localhost:3030/
    - framework: React (Next.js)
    - bundler: Webpack
```


### Stack trace

_No response_

### Additional context

It looks parsing `Cargo.toml` is only for several checks so option to skip such a checks is one possible solution I think.

Rust 2024 is planned to be stabilized in rust 1.82.0 which will be released on October 17th so I tried them with nightly toolchain.


Discussion / hints:
@anatawa12 can you test the `feat/1.x-edition-2024` branch from #10414 and see if it works for your project?
I tried a915361ddc6e63c749478f05bcb5ced9ad814aea and it works for my project. thank you

Fix patch:
diff --git a/.changes/change-pr-12270.md b/.changes/change-pr-12270.md
new file mode 100644
index 000000000000..9557656d0667
--- /dev/null
+++ b/.changes/change-pr-12270.md
@@ -0,0 +1,5 @@
+---
+"tauri-build": "patch:bug"
+---
+
+Update `cargo_toml` to `0.21.0`. This adds compatibility with Rust's 2024 Edition.
diff --git a/Cargo.lock b/Cargo.lock
index 1b01969af5e9..672e907703cb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1561,9 +1561,9 @@ dependencies = [
 
 [[package]]
 name = "cargo_toml"
-version = "0.17.2"
+version = "0.21.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a969e13a7589e9e3e4207e153bae624ade2b5622fb4684a4923b23ec3d57719"
+checksum = "5fbd1fe9db3ebf71b89060adaf7b0504c2d6a425cf061313099547e382c2e472"
 dependencies = [
  "serde",
  "toml 0.8.19",
diff --git a/crates/tauri-build/Cargo.toml b/crates/tauri-build/Cargo.toml
index c6a8972b8d62..9738c27b51cc 100644
--- a/crates/tauri-build/Cargo.toml
+++ b/crates/tauri-build/Cargo.toml
@@ -33,7 +33,7 @@ tauri-utils = { version = "2.1.1", path = "../tauri-utils", features = [
   "build",
   "resources",
 ] }
-cargo_toml = "0.17"
+cargo_toml = "0.21"
 serde = "1"
 serde_json = "1"
 heck = "0.5"
diff --git a/crates/tauri-build/src/lib.rs b/crates/tauri-build/src/lib.rs
index a1dd235ea26c..a4033d76bd2f 100644
--- a/crates/tauri-build/src/lib.rs
+++ b/crates/tauri-build/src/lib.rs
@@ -506,19 +506,8 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
 
   cfg_alias("dev", is_dev());
 
-  let ws_path = get_workspace_dir()?;
-  let mut manifest =
-    Manifest::<cargo_toml::Value>::from_slice_with_metadata(&fs::read("Cargo.toml")?)?;
-
-  if let Ok(ws_manifest) = Manifest::from_path(ws_path.join("Cargo.toml")) {
-    Manifest::complete_from_path_and_workspace(
-      &mut manifest,
-      Path::new("Cargo.toml"),
-      Some((&ws_manifest, ws_path.as_path())),
-    )?;
-  } else {
-    Manifest::complete_from_path(&mut manifest, Path::new("Cargo.toml"))?;
-  }
+  let cargo_toml_path = Path::new("Cargo.toml").canonicalize()?;
+  let mut manifest = Manifest::<cargo_toml::Value>::from_path_with_metadata(cargo_toml_path)?;
 
   let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
 
@@ -701,23 +690,3 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
 
   Ok(())
 }
-
-#[derive(serde::Deserialize)]
-struct CargoMetadata {
-  workspace_root: PathBuf,
-}
-
-fn get_workspace_dir() -> Result<PathBuf> {
-  let output = std::process::Command::new("cargo")
-    .args(["metadata", "--no-deps", "--format-version", "1"])
-    .output()?;
-
-  if !output.status.success() {
-    return Err(anyhow::anyhow!(
-      "cargo metadata command exited with a non zero exit code: {}",
-      String::from_utf8(output.stderr)?
-    ));
-  }
-
-  Ok(serde_json::from_slice::<CargoMetadata>(&output.stdout)?.workspace_root)
-}
diff --git a/crates/tauri/Cargo.toml b/crates/tauri/Cargo.toml
index e7a39710fa7d..d5492ed72195 100644
--- a/crates/tauri/Cargo.toml
+++ b/crates/tauri/Cargo.toml
@@ -150,7 +150,7 @@ serde = { version = "1", features = ["derive"] }
 serde_json = "1"
 tauri = { path = ".", default-features = false, features = ["wry"] }
 tokio = { version = "1", features = ["full"] }
-cargo_toml = "0.17"
+cargo_toml = "0.21"
 http-range = "0.1.5"
 
 # macOS


Test patch: