tauri-apps/tauri · error

failed to read binary path

Error message

failed to read binary path

What it means

For each non-main binary, generate_binaries_data converts settings.binary_path(bin) into a String via into_string().expect("failed to read binary path"). This panics when the resolved binary path is not valid UTF-8, because OsString::into_string returns Err for non-UTF-8 content.

Solutions

  1. Move the project (or set CARGO_TARGET_DIR) to an ASCII-only path and rebuild.
  2. On Windows, enable UTF-8 codepage (Beta: Use Unicode UTF-8 for worldwide language support) or set the build environment to UTF-8.
  3. Replace the expect with to_string_lossy() or a proper error to make the failure diagnosable.

Example fix

// before
path: settings.binary_path(bin).into_os_string().into_string().expect("failed to read binary path"),

// after
path: settings.binary_path(bin).to_string_lossy().into_owned(),
Defensive patterns

Strategy: validation

Validate before calling

// verify project and target dirs are UTF-8 before bundling
for p in [project_dir.clone(), target_dir.clone()] {
  if p.to_str().is_none() {
    return Err(anyhow!("path is not valid UTF-8: {}", p.to_string_lossy()));
  }
}

Type guard

fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }

Try / catch

// run bundling in a child process and translate the panic into
// 'move project/target dir to a UTF-8-safe path'.

Prevention

When it happens

Trigger: Calling bundle_project when the project or target directory path contains characters outside UTF-8 (legacy codepage characters, raw bytes in symlink targets) such that binary_path() yields a non-UTF-8 OsString.

Common situations: Building from a directory path with non-ASCII characters on Windows with a legacy codepage, or a target/ directory placed under such a path via CARGO_TARGET_DIR.

Related errors


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

Appendix: source

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

    binaries.push(Binary {
      guid: Uuid::new_v4().to_string(),
      path: dest
        .into_os_string()
        .into_string()
        .expect("failed to read external binary path"),
      id: wix_identifier(&dest_filename),
    });
  }

  for bin in settings.binaries() {
    if !bin.main() {
      binaries.push(Binary {
        guid: Uuid::new_v4().to_string(),
        path: settings
          .binary_path(bin)
          .into_os_string()
          .into_string()
          .expect("failed to read binary path"),
        id: wix_identifier(bin.name()),
      })
    }
  }

  Ok(binaries)
}

#[derive(Serialize)]
struct MergeModule {
  name: String,
  path: String,
}

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(

View on GitHub (pinned to 460ec35447)