tauri-apps/tauri · error

failed to read external binary path

Error message

failed to read external binary path

What it means

After copying an external binary into the temp dir, generate_binaries_data converts the destination OsString into a String via into_string().expect("failed to read external binary path"). into_string() fails only when the path contains non-UTF-8 bytes, so the panic means the temp path to the binary is not valid UTF-8.

Solutions

  1. Set TMP/TEMP to a simple ASCII path (e.g. C:\tmp) before building.
  2. If controlled by config, keep project/user paths ASCII; rename the Windows account or use a dedicated build user.
  3. Patch the expect into a proper error (into_string().map_err(...)? ) so the failure is reported instead of panicking.

Example fix

// before
path: dest.into_os_string().into_string().expect("failed to read external binary path"),

// after
path: dest.to_string_lossy().into_owned(),
Defensive patterns

Strategy: validation

Validate before calling

// ensure the temp dir is ASCII/UTF-8 before bundling
let tmp = std::env::temp_dir();
let s = tmp.to_string_lossy();
if s != tmp.to_str().unwrap_or("\u{0}nonutf8") {
  return Err(anyhow!("TMP path is not valid UTF-8: {}", s));
}

Type guard

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

Try / catch

// catch the abort: run bundling in a subprocess and map the panic message to
// 'set TMP/TEMP to an ASCII-only directory'.

Prevention

When it happens

Trigger: Calling bundle_project when the temp directory path (std::env::temp_dir(), often TMP/TEMP) contains non-UTF-8 characters — e.g. a Windows username or TMP variable with accented/CJK characters in a non-UTF-8 codepage.

Common situations: Windows CI machines or developer accounts where %TEMP% resolves under a user profile with non-ASCII characters (é, ñ, Chinese characters) while the system uses a legacy codepage.

Related errors


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

Appendix: source

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

  let cwd = std::env::current_dir()?;
  let tmp_dir = std::env::temp_dir();
  for src in settings.external_binaries() {
    let src = src?;
    let binary_path = cwd.join(&src);
    let dest_filename = src
      .file_name()
      .expect("failed to extract external binary filename")
      .to_string_lossy()
      .replace(&format!("-{}", settings.target()), "");
    let dest = tmp_dir.join(&dest_filename);
    std::fs::copy(binary_path, &dest)?;

    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()),
      })
    }
  }

View on GitHub (pinned to 460ec35447)