{"record":{"id":"be67ded5a564f493","repo":"tauri-apps/tauri","slug":"failed-to-setup-handlebar-template","errorCode":null,"errorMessage":"Failed to setup handlebar template","messagePattern":"Failed to setup handlebar template","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/windows/msi/mod.rs","lineNumber":743,"sourceCode":"    let schemes = protocols\n      .iter()\n      .flat_map(|p| &p.schemes)\n      .collect::<Vec<_>>();\n    if !schemes.is_empty() {\n      data.insert(\"deep_link_protocols\", to_json(schemes));\n    }\n  }\n\n  if let Some(path) = custom_template_path {\n    handlebars\n      .register_template_string(\"main.wxs\", fs::read_to_string(path)?)\n      .map_err(|e| e.to_string())\n      .expect(\"Failed to setup custom handlebar template\");\n  } else {\n    handlebars\n      .register_template_string(\"main.wxs\", include_str!(\"./main.wxs\"))\n      .map_err(|e| e.to_string())\n      .expect(\"Failed to setup handlebar template\");\n  }\n\n  if enable_elevated_update_task {\n    data.insert(\n      \"msiexec_args\",\n      to_json(\n        settings\n          .updater()\n          .map(|updater| updater.msiexec_args)\n          .map(|args| args.join(\" \"))\n          .unwrap_or_else(|| \"/passive\".to_string()),\n      ),\n    );\n\n    // Create the update task XML\n    let skip_uac_task = Handlebars::new();\n    let xml = include_str!(\"./update-task.xml\");\n    let update_content = skip_uac_task.render_template(xml, &data)?;","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-bundler/src/bundle/windows/msi/mod.rs#L725-L761","documentation":"The MSI bundler registers its built-in main.wxs (embedded via include_str!) as a Handlebars template. The built-in template ships and is tested with the crate, so this expect indicates a corrupted/vendored install or a handlebars dependency regression rather than anything in your tauri.conf.json.","triggerScenarios":"tauri build --bundles msi with no custom template configured, where the embedded main.wxs fails Handlebars compilation — e.g. a patched or vendored tauri-bundler whose template edits do not compile, or a dependency resolution that changes Handlebars parsing behavior.","commonSituations":"Vendored/forked tauri-bundler with local template edits; downgrading handlebars alongside the bundler; corrupted cargo registry cache serving mismatched crate sources.","solutions":["Install a matching official release: cargo install tauri-cli --locked (or the npm/pnpm/cargo-binstall equivalent) and rebuild","Clear the cached tauri-bundler sources (cargo registry cache) and rebuild so the pristine template is re-extracted","If vendoring the bundler, ensure local main.wxs edits compile against the pinned handlebars version before shipping"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# confirm the CLI and crate pair are an official matching release\ncargo tauri --version\ncargo tree -i tauri-bundler 2>/dev/null || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install tauri-cli with --locked so dependency resolution matches tested versions","Do not pin handlebars separately in projects that wrap tauri-bundler","Upgrade the CLI and the tauri framework together, and avoid vendoring template edits without compile checks"],"tags":["windows","msi","wix","handlebars","template","internal","tauri-bundler"],"backgroundTag":"template-parse-error","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}