{"record":{"id":"923c4edd41939ebd","repo":"tauri-apps/tauri","slug":"failed-to-create-locale-file","errorCode":null,"errorMessage":"Failed to create locale file","messagePattern":"Failed to create locale file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/windows/msi/mod.rs","lineNumber":880,"sourceCode":"    for locale_string in locale_strings.split('\\n').filter(|s| !s.is_empty()) {\n      // strip `<String ` prefix and `>{value}</String` suffix.\n      let id = locale_string\n        .chars()\n        .skip(prefix_len)\n        .take(locale_string.find('>').unwrap() - prefix_len)\n        .collect::<String>();\n      if !locale_contents.contains(&id) {\n        unset_locale_strings.push_str(locale_string);\n      }\n    }\n\n    let locale_contents = locale_contents.replace(\n      \"</WixLocalization>\",\n      &format!(\"{unset_locale_strings}</WixLocalization>\"),\n    );\n    let locale_path = output_path.join(\"locale.wxl\");\n    {\n      let mut fileout = File::create(&locale_path).expect(\"Failed to create locale file\");\n      fileout.write_all(locale_contents.as_bytes())?;\n    }\n\n    let arguments = vec![\n      format!(\n        \"-cultures:{}\",\n        if language == \"en-US\" {\n          language.to_lowercase()\n        } else {\n          format!(\"{};en-US\", language.to_lowercase())\n        }\n      ),\n      \"-loc\".into(),\n      display_path(&locale_path),\n      \"*.wixobj\".into(),\n    ];\n    let msi_output_path = output_path.join(\"output.msi\");\n    let msi_path =","sourceCodeStart":862,"sourceCodeEnd":898,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/bundle/windows/msi/mod.rs#L862-L898","documentation":"While building the MSI, tauri-bundler writes a locale.wxl file (WiX localization strings, possibly augmented with unset-locale strings) into the WiX output directory. If File::create on locale.wxl fails, the code panics with .expect(\"Failed to create locale file\"). File::create fails when the target directory does not exist or the process lacks write permission.","triggerScenarios":"Calling bundle_project with bundle.windows.wix.language configured, when the parent directory of output_path/locale.wxl was removed between steps, output_path is read-only, an antivirus/file lock blocks creation, or the path is on a full disk.","commonSituations":"CI runners with read-only build directories, target/release/bundle cleaned while bundling, antivirus quarantining files mid-build on Windows, or output paths pointing to a drive without space.","solutions":["Ensure the bundle output directory (target/release/bundle/msi/...) exists and is writable; re-run the build to regenerate it.","Check disk space and remove any lock on the directory (antivirus scans, open Explorer windows, previous MSI processes).","Run the build with sufficient permissions, or point the output to a user-writable location.","Retry the build — transient AV/file-lock failures usually disappear on a second run."],"exampleFix":"// before\nlet mut fileout = File::create(&locale_path).expect(\"Failed to create locale file\");\n\n// after\nlet mut fileout = File::create(&locale_path)\n  .with_context(|| format!(\"failed to create locale file at {}\", locale_path.display()))?;","handlingStrategy":"try-catch","validationCode":"// precheck before bundling\nlet dir = std::path::Path::new(\"target/release/bundle/msi\");\nfs::create_dir_all(dir)?;\nlet probe = dir.join(\".write_probe\");\nfs::write(&probe, b\"x\").map_err(|e| anyhow!(\"bundle dir not writable: {}\", e))?;\nlet _ = fs::remove_file(&probe);","typeGuard":null,"tryCatchPattern":"// run the bundler in a child process and treat a panic here as an environment error:\nlet status = Command::new(\"cargo\").args([\"tauri\", \"build\"]).status()?;\nif !status.success() { /* inspect output for 'Failed to create locale file' */ }","preventionTips":["Ensure the bundle output directory exists and is writable before building","Exclude target/ and bundle output dirs from antivirus real-time scanning","Monitor disk space on CI runners","Avoid locking bundle dirs in Explorer or other processes during builds"],"tags":["wix","msi","windows","file-write"],"backgroundTag":"file-write-failed","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}