tauri-apps/tauri · error
Failed to open file
Error message
Failed to open file
What it means
In extract_zip, after reading a zip entry into a buffer, tauri-bundler creates the destination file with File::create(dest_path).expect("Failed to open file"). Any OS-level failure to create/overwrite that file (permissions, path length, read-only, name collision with a directory) becomes this panic instead of a graceful error.
Solutions
- Delete the existing WiX tools cache (e.g. %LOCALAPPDATA%/tauri/WixTools3139) and re-run the build so files are recreated fresh.
- Add an antivirus exclusion for the tauri cache directory or temporarily disable real-time scanning during the build.
- Run the build from an elevated shell or fix ACLs on the cache directory so it is writable.
- Enable Windows long-path support (LongPathsEnabled) or move the cache to a shorter path.
Example fix
// before (run in project shell) tauri build // after (clear the bad cache first, PowerShell) Remove-Item -Recurse -Force "$env:LOCALAPPDATA\tauri\WixTools*" tauri build
Defensive patterns
Strategy: try-catch
Validate before calling
// Check the WiX cache directory is writable before extraction
use std::path::Path;
let probe = cache_dir.join(".write_probe");
std::fs::write(&probe, b"x").expect("WiX cache dir not writable (AV lock or permissions?)");
let _ = std::fs::remove_file(&probe); Try / catch
// Catch OS-level write failures during WiX setup
if let Err(e) = ensure_wix(&cache_dir) {
eprintln!("WiX extraction failed: {e}; clearing cache and retrying");
let _ = std::fs::remove_dir_all(&cache_dir);
ensure_wix(&cache_dir)?;
} Prevention
- Add an antivirus exclusion for the tauri cache directory.
- Enable Windows long paths and keep the cache path short.
- Run builds with write access to %LOCALAPPDATA% and clean stale read-only caches.
When it happens
Trigger: get_and_extract_wix -> extract_zip when File::create on a zip entry's destination fails: destination is inside a read-only directory, an antivirus locks the file, the path exceeds MAX_PATH on Windows, or a directory already exists with the same name.
Common situations: Windows Defender/AV scanning quarantines files during WiX extraction; previously extracted WiX cache contains read-only files or a directory where a file should be; long paths under deep %LOCALAPPDATA% cache; running without write permission to the cache dir.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Failed to get parent
- Failed to create locale file
- app version build number cannot be greater than 65535
- app version major number cannot be greater than 255
- app version minor number cannot be greater than 255
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/21fe3d5aeab63702.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri-bundler/src/utils/http_utils.rs:180
for i in 0..zipa.len() {
let mut file = zipa.by_index(i)?;
if let Some(name) = file.enclosed_name() {
let dest_path = path.join(name);
if file.is_dir() {
create_dir_all(&dest_path)?;
continue;
}
let parent = dest_path.parent().expect("Failed to get parent");
if !parent.exists() {
create_dir_all(parent)?;
}
let mut buff: Vec<u8> = Vec::new();
file.read_to_end(&mut buff)?;
let mut fileout = File::create(dest_path).expect("Failed to open file");
fileout.write_all(&buff)?;
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::generate_github_mirror_url_from_template;
use std::env;
const GITHUB_ASSET_URL: &str =
"https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip";
const NON_GITHUB_ASSET_URL: &str = "https://someotherwebsite.com/somefile.zip";
#[test]View on GitHub (pinned to 460ec35447)