tauri-apps/tauri · error

failed to read resource folder name

Error message

failed to read resource folder name

What it means

When composing the WiX directory tree for an MSI, the bundler converts each component of a resource's target path to a String with OsString::into_string(). That conversion fails (returns Err) if the component contains non-UTF-8 bytes, and this expect() panics with 'failed to read resource folder name'. It means an intermediate directory in a resource target is not valid Unicode on your system.

Source

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

          .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()
        .into_string()
        .expect("failed to read resource folder name");

      directory_entry = directory_entry
        .directories
        .entry(directory_name)
        .or_default();
    }
    directory_entry.add_file(resource_entry);
  }

  let mut dlls = Vec::new();

  if settings.windows().bundle_vc_runtime {
    for dll in vc_runtime_dlls(settings.binary_arch())? {
      let resource_path = dunce::simplified(&dll);
      if added_resources.contains(&resource_path.to_path_buf()) {
        continue;
      }
      added_resources.insert(resource_path.to_path_buf());

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Ensure tauri.conf.json is saved as UTF-8 and every resources target string is valid UTF-8.
  2. If a glob is picking up directories with non-Unicode names, narrow the glob or rename the offending folder to ASCII/UTF-8.
  3. Avoid intermediate directory names with characters outside the system's Unicode capabilities when remapping resources for MSI builds.
  4. As a last resort, bundle those files via NSIS or place them so the MSI target tree only uses ASCII directory names.

Example fix

// before: glob sweeps non-UTF-8 folders
"resources": [ "assets/**/*" ]

// after: explicit UTF-8-safe targets
"resources": { "assets/safe/icon.png": "icons/icon.png" }
Defensive patterns

Strategy: validation

Validate before calling

// Fail fast on non-UTF-8 target components before bundling
let ok = resources_targets.iter().all(|t| {
    Path::new(t).components().all(|c| c.as_os_str().to_str().is_some())
});
assert!(ok, "resource targets must be valid UTF-8 for MSI builds");

Prevention

When it happens

Trigger: MSI bundling (`tauri build` with the msi bundle) where a resource's target path contains a directory component that is not valid UTF-8 — e.g. a target read from a non-UTF-8 tauri.conf.json on Windows with a legacy code page, or a target built from a glob that matched a filesystem directory with non-Unicode characters. The panic fires at crates/tauri-bundler/src/bundle/windows/msi/mod.rs:1043 while building root_resource_directory.

Common situations: Resource globs that sweep up user-named folders with localized/emoji/non-ANSI characters on Windows; config files edited with tools that save non-UTF-8 encodings; paths copied from Explorer on systems where the active code page mangles names.

Related errors


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