tauri-apps/tauri · error

failed to read resource folder name

Error message

failed to read resource folder name

What it means

generate_resource_data splits each resource target directory into components and converts every component from OsStr to String with into_string().expect("failed to read resource folder name"). The panic occurs when a directory component of the resource target path is not valid UTF-8.

Solutions

  1. Rename resource folders to ASCII-only names, or move resources to an ASCII path and update the resources config.
  2. Enable UTF-8 support on the build machine (Windows 'Use Unicode UTF-8 for worldwide language support').
  3. Patch the conversion to to_string_lossy() so such paths are tolerated.

Example fix

// before
let directory_name = directory.as_os_str().to_os_string().into_string()
  .expect("failed to read resource folder name");

// after
let directory_name = directory.as_os_str().to_string_lossy().into_owned();
Defensive patterns

Strategy: validation

Validate before calling

// check resource target components are UTF-8
let comps = resource.target().components();
for c in comps {
  if c.as_os_str().to_str().is_none() {
    return Err(anyhow!("non-UTF-8 folder name in resource target: {}", c.as_os_str().to_string_lossy()));
  }
}

Type guard

fn all_utf8_components(p: &std::path::Path) -> bool {
  p.components().all(|c| c.as_os_str().to_str().is_some())
}

Try / catch

// run bundling in a child process; on panic, instruct renaming resource folders
// to UTF-8/ASCII-safe names.

Prevention

When it happens

Trigger: Calling bundle_project with a resources entry whose target directory path (or any intermediate folder name on the machine) contains non-UTF-8 bytes — typical on Windows with legacy codepage paths (accented/CJK characters stored as raw bytes).

Common situations: Bundling resources located under directories with non-ASCII names on a Windows machine using a legacy codepage, or copying resources from an archive that preserved non-UTF-8 filenames.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/beb3e8df626bbfa8. Report an issue: GitHub.

Appendix: source

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

          .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 460ec35447)