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 to the temp directory, the MSI bundler converts the destination path to a UTF-8 String for the WiX data. into_string() fails when the OsString is not valid UTF-8 — i.e. the temp-directory path contains non-UTF-8 bytes (unpaired surrogates in a Windows user name, or a non-UTF-8 TMPDIR on Unix cross-builds).
Source
Thrown at crates/tauri-bundler/src/bundle/windows/msi/mod.rs:940
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 52e4b6e71d)
Solutions
- Point TMP/TEMP at an ASCII path for the build: set TMP=C:\tmp && set TEMP=C:\tmp && tauri build --bundles msi
- Build from an account with a plain-ASCII user name, or redirect the temp directory per-process
- On Unix cross-builds, export TMPDIR=/tmp explicitly before invoking the bundler
Example fix
:: before tauri build --bundles msi :: after (Windows cmd) set TMP=C:\tmp set TEMP=C:\tmp tauri build --bundles msi
Defensive patterns
Strategy: validation
Validate before calling
// fail fast when TMP is not UTF-8 representable before MSI bundling with sidecars
if let Err(_) = std::env::temp_dir().into_os_string().into_string() {
eprintln!("TMP path is not valid UTF-8; set TMP/TEMP to an ASCII directory before bundling");
std::process::exit(1);
} Prevention
- Use ASCII paths for TMP/TEMP and project directories on Windows build machines
- Avoid user accounts with legacy or surrogate Unicode names for builds
- Set TMPDIR explicitly in cross-build containers
When it happens
Trigger: MSI bundling on a machine whose TMP/TEMP path is not representable as UTF-8: a Windows account name containing unpaired surrogates, or a Unix build container with non-UTF-8 bytes in TMPDIR — hit only when bundle.externalBin is non-empty.
Common situations: Windows usernames with rare or legacy Unicode; systems where TMP is redirected to an oddly encoded path; cross-compilation containers that inherit a binary-unsafe TMPDIR.
Related errors
- failed to extract external binary filename
- failed to read binary path
- failed to convert merge module filename to string
- Language {} not found. It must be one of {}
- Failed to setup custom handlebar template
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/7de1fd0ac13205d9.
Report an issue: GitHub.