tauri-apps/tauri · error

failed to read resource file name

Error message

failed to read resource file name

What it means

While building an MSI installer, the bundler walks every configured resource's target path and calls Path::file_name() to derive the file name that WiX will register. file_name() returns None when the path terminates in '..' or is otherwise a path with no final component, and this expect() turns that None into a panic. So the error means a resources entry in tauri.conf.json has a target whose last component is not a real file name.

Source

Thrown at crates/tauri-bundler/src/bundle/windows/msi/mod.rs:1023

    // In some glob resource paths like `assets/**/*` a file might appear twice
    // because the `tauri_utils::resources::ResourcePaths` iterator also reads a directory
    // when it finds one. So we must check it before processing the file.
    if added_resources.contains(&resource_path) {
      continue;
    }
    added_resources.insert(resource_path.clone());

    if settings.windows().can_sign() && should_sign(&resource_path)? {
      try_sign(&resource_path, settings)?;
    }

    let resource_entry = ResourceFile::new(
      resource_path,
      Some(
        resource
          .target()
          .file_name()
          .expect("failed to read resource file name")
          .to_string_lossy()
          .into_owned(),
      ),
    );

    let target_path = resource.target();
    let components_count = target_path.components().count();
    let directories = target_path
      .components()
      .take(components_count - 1) // the last component is the file
      .collect::<Vec<_>>();

    let mut directory_entry = &mut root_resource_directory;

    for directory in directories {
      let directory_name = directory
        .as_os_str()
        .to_os_string()

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Check every entry in build > resources in tauri.conf.json and make sure each target path ends with a concrete file name (or is a plain glob whose targets keep their file names).
  2. Remove trailing '/..' or '/' components from target values; a target must name a file, not a directory traversal.
  3. If you intended a whole directory, list it as a single source without a remapping target, or enumerate its files so each target ends in a file name.
  4. Re-run `tauri build --bundles msi` to confirm the panic is gone.

Example fix

// tauri.conf.json — before
"resources": { "assets/icon.png": "icons/.." }

// after
"resources": { "assets/icon.png": "icons/icon.png" }
Defensive patterns

Strategy: validation

Validate before calling

// Before building, validate every resources target ends in a file name
fn valid_targets(resources: &serde_json::Value) -> bool {
    match resources {
        serde_json::Value::Array(items) => items.iter().all(|v| {
            v.as_str().map(|s| Path::new(s).file_name().is_some()).unwrap_or(false)
        }),
        serde_json::Value::Object(map) => map.values().all(|v| {
            v.as_str().map(|s| Path::new(s).file_name().is_some()).unwrap_or(false)
        }),
        _ => true,
    }
}

Prevention

When it happens

Trigger: Running `tauri build` (or `cargo tauri build`) with the MSI bundle target on Windows, where bundle > resources contains an entry whose target path ends in '..' (e.g. {"src": "assets/x.png", "target": "stuff/.."}) or is a root-like path with no file component. The MSI path calls resource.target().file_name() at crates/tauri-bundler/src/bundle/windows/msi/mod.rs:1023; the NSIS path handles targets differently, so this only panics for MSI/WiX builds.

Common situations: Typos in the resources map such as a target of "data/.." or ""; using a glob-expanded resource whose computed target collapses to a directory-level path; copying a resources config from a script that accidentally appends '/..' or strips the file name.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/5f1af45659f4dfd0. Report an issue: GitHub.