{"record":{"id":"19b6d20630693208","repo":"tauri-apps/tauri","slug":"failed-to-convert-merge-module-filename-to-string","errorCode":null,"errorMessage":"failed to convert merge module filename to string","messagePattern":"failed to convert merge module filename to string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/windows/msi/mod.rs","lineNumber":988,"sourceCode":"}\n\nfn get_merge_modules(settings: &Settings) -> crate::Result<Vec<MergeModule>> {\n  let mut merge_modules = Vec::new();\n  let regex = Regex::new(r\"[^\\w\\d\\.]\")?;\n  for msm in glob::glob(\n    &PathBuf::from(glob::Pattern::escape(\n      &settings.project_out_directory().to_string_lossy(),\n    ))\n    .join(\"*.msm\")\n    .to_string_lossy(),\n  )? {\n    let path = msm?;\n    let filename = path\n      .file_name()\n      .expect(\"failed to extract merge module filename\")\n      .to_os_string()\n      .into_string()\n      .expect(\"failed to convert merge module filename to string\");\n    merge_modules.push(MergeModule {\n      name: regex.replace_all(&filename, \"\").to_string(),\n      path: path.to_string_lossy().to_string(),\n    });\n  }\n  Ok(merge_modules)\n}\n\n/// Generates the data required for the resource bundling on wix\nfn generate_resource_data(settings: &Settings) -> crate::Result<ResourceDirectory> {\n  let cwd = std::env::current_dir()?;\n\n  let mut root_resource_directory = ResourceDirectory::default();\n  let mut added_resources = HashSet::new();\n\n  for resource in settings.resource_files().iter() {\n    let resource = resource?;\n","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/bundle/windows/msi/mod.rs#L970-L1006","documentation":"Immediately after extracting the merge module filename, get_merge_modules converts it from OsString to String with into_string().expect(\"failed to convert merge module filename to string\"). This panics when the .msm filename contains non-UTF-8 bytes.","triggerScenarios":"Calling bundle_project when an .msm file inside the merge-modules directory has a filename with non-UTF-8 characters (e.g. encoded in a legacy Windows codepage), so into_string() returns Err.","commonSituations":"Merge modules downloaded/copied from external sources with localized filenames (accented or CJK characters) stored with a legacy codepage on a Windows machine not using UTF-8.","solutions":["Rename the .msm files to ASCII-only names before bundling.","Enable UTF-8 codepage on Windows (system locale settings) or fix the source of the oddly-encoded filenames.","Patch the code to use to_string_lossy() so non-UTF-8 filenames are handled instead of panicking."],"exampleFix":"// before\n.into_string().expect(\"failed to convert merge module filename to string\");\n\n// after\n.to_string_lossy().into_owned();","handlingStrategy":"validation","validationCode":"// ensure every .msm filename is UTF-8 before bundling\nfor entry in glob(\"**/*.msm\")? {\n  let p = entry?;\n  if p.file_name().and_then(|n| n.to_str()).is_none() {\n    return Err(anyhow!(\"non-UTF-8 merge module name: {}\", p.to_string_lossy()));\n  }\n}","typeGuard":"fn is_utf8_os(s: &std::ffi::OsStr) -> bool { s.to_str().is_some() }","tryCatchPattern":"// catch via subprocess isolation; instruct users to rename .msm files to ASCII names.","preventionTips":["Rename merge modules to ASCII-only filenames before adding them to the project","Normalize filenames when downloading/copying .msm files (unzip with UTF-8 flags)","Enable UTF-8 codepage on Windows build machines"],"tags":["msi","wix","windows","encoding","utf-8"],"backgroundTag":"non-utf8-path","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"}