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

Issue:
[bug] `core:` permission identifiers missing in schema files when the project path contains special characters
### Describe the bug

Schema files cannot be properly generated when the project is in a path that contains special characters (square brackets `[]` in my case). Permission identifiers starting with `core:` are missing. And I don't see any error reported by the program during the generation process.
![](https://media.discordapp.net/attachments/1314251088949678100/1316482290049613834/image.png?ex=675b352d&is=6759e3ad&hm=18229b73a5c3b6f4952aa527d24b2f1e3d1aab31fc47c0434476f234f7ab9937&=&format=webp&quality=lossless&width=1735&height=651)
![](https://media.discordapp.net/attachments/1314251088949678100/1316492578966737006/a6b0a10076d3b62aafe50fa0e5d42dec.png?ex=675b3ec2&is=6759ed42&hm=06554ac622b917bcec9e5a5d3ea379e53abee1351ccf0a6b25700641cbae8982&=&format=webp&quality=lossless&width=1735&height=663)

### Reproduction

Create a new project using `pnpm create tauri-app` in a path that contains special characters (e.g. `[]`), open in VS Code, and wait for rust-analyzer to finish running tasks. Reproducible on both Windows and macOS.

### Expected behavior

Either the file generation should work properly, or the program should report errors and clearly indicate that it should not run under such paths.

### Full `tauri info` output

Windows:
```text
[✔] Environment
    - OS: Windows 10.0.26100 x86_64 (X64)
    ✔ WebView2: 131.0.2903.86
    ✔ MSVC:
        - Visual Studio Community 2022
        - Visual Studio 生成工具 2022
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.1
    - pnpm: 9.14.2
    - npm: 10.2.4

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - tauri-cli 🦀: 2.1.0
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
```

macOS:
```text
[✔] Environment
    - OS: Mac OS 15.1.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 1.83.0 (5ffbef321 2024-10-29)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 23.1.0
    - pnpm: 9.15.0
    - npm: 10.9.0

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
```


### Stack trace

_No response_

### Additional context

_No response_


Discussion / hints:

Fix patch:
diff --git a/.changes/escape-glob.md b/.changes/escape-glob.md
new file mode 100644
index 000000000000..67988e697bae
--- /dev/null
+++ b/.changes/escape-glob.md
@@ -0,0 +1,7 @@
+---
+"tauri": "patch:bug"
+"tauri-build": "patch:bug"
+"tauri-bundler": "patch:bug"
+---
+
+Fix tauri fails to build if the project path contains glob characters
diff --git a/crates/tauri-build/src/acl.rs b/crates/tauri-build/src/acl.rs
index d1a1e6f647ca..be6512ab357a 100644
--- a/crates/tauri-build/src/acl.rs
+++ b/crates/tauri-build/src/acl.rs
@@ -199,7 +199,9 @@ permissions = [{default_permissions}]
       }
 
       tauri_utils::acl::build::define_permissions(
-        &plugin_out_dir.join("*").to_string_lossy(),
+        &PathBuf::from(glob::Pattern::escape(&plugin_out_dir.to_string_lossy()))
+          .join("*")
+          .to_string_lossy(),
         name,
         &plugin_out_dir,
         |_| true,
@@ -222,10 +224,12 @@ permissions = [{default_permissions}]
         );
       }
       permission_files.extend(tauri_utils::acl::build::define_permissions(
-        &default_permissions_path
-          .join("**")
-          .join("*")
-          .to_string_lossy(),
+        &PathBuf::from(glob::Pattern::escape(
+          &default_permissions_path.to_string_lossy(),
+        ))
+        .join("**")
+        .join("*")
+        .to_string_lossy(),
         name,
         &plugin_out_dir,
         |_| true,
diff --git a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs
index e899c52e913a..6eef04fae0f1 100644
--- a/crates/tauri-bundler/src/bundle/windows/msi/mod.rs
+++ b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs
@@ -929,12 +929,11 @@ fn get_merge_modules(settings: &Settings) -> crate::Result<Vec<MergeModule>> {
   let mut merge_modules = Vec::new();
   let regex = Regex::new(r"[^\w\d\.]")?;
   for msm in glob::glob(
-    settings
-      .project_out_directory()
-      .join("*.msm")
-      .to_string_lossy()
-      .to_string()
-      .as_str(),
+    &PathBuf::from(glob::Pattern::escape(
+      &settings.project_out_directory().to_string_lossy(),
+    ))
+    .join("*.msm")
+    .to_string_lossy(),
   )? {
     let path = msm?;
     let filename = path
@@ -1042,7 +1041,11 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
   let mut dlls = Vec::new();
 
   let out_dir = settings.project_out_directory();
-  for dll in glob::glob(out_dir.join("*.dll").to_string_lossy().to_string().as_str())? {
+  for dll in glob::glob(
+    &PathBuf::from(glob::Pattern::escape(&out_dir.to_string_lossy()))
+      .join("*.dll")
+      .to_string_lossy(),
+  )? {
     let path = dll?;
     let resource_path = dunce::simplified(&path);
     let relative_path = path
diff --git a/crates/tauri/Cargo.toml b/crates/tauri/Cargo.toml
index a4f62dd65fc8..44bc8902b957 100644
--- a/crates/tauri/Cargo.toml
+++ b/crates/tauri/Cargo.toml
@@ -136,6 +136,7 @@ libc = "0.2"
 swift-rs = "1.0.7"
 
 [build-dependencies]
+glob = "0.3"
 heck = "0.5"
 tauri-build = { path = "../tauri-build/", default-features = false, version = "2.0.3" }
 tauri-utils = { path = "../tauri-utils/", version = "2.1.0", features = [
diff --git a/crates/tauri/build.rs b/crates/tauri/build.rs
index 6d42d967b4ce..ba9565d0a3e1 100644
--- a/crates/tauri/build.rs
+++ b/crates/tauri/build.rs
@@ -376,10 +376,12 @@ permissions = [{default_permissions}]
       .unwrap_or_else(|_| panic!("unable to autogenerate default permissions"));
 
     let permissions = tauri_utils::acl::build::define_permissions(
-      &permissions_out_dir
-        .join("**")
-        .join("*.toml")
-        .to_string_lossy(),
+      &PathBuf::from(glob::Pattern::escape(
+        &permissions_out_dir.to_string_lossy(),
+      ))
+      .join("**")
+      .join("*.toml")
+      .to_string_lossy(),
       &format!("tauri:{plugin}"),
       out_dir,
       |_| true,
@@ -432,7 +434,11 @@ permissions = [{}]
     .unwrap_or_else(|_| panic!("unable to autogenerate core:default set"));
 
   let _ = tauri_utils::acl::build::define_permissions(
-    &permissions_out_dir.join("*.toml").to_string_lossy(),
+    &PathBuf::from(glob::Pattern::escape(
+      &permissions_out_dir.to_string_lossy(),
+    ))
+    .join("*.toml")
+    .to_string_lossy(),
     "tauri:core",
     out_dir,
     |_| true,


Test patch: