{"record":{"id":"b7d1768227f6b008","repo":"tauri-apps/tauri","slug":"failed-to-render-tauri-conf-json-template","errorCode":null,"errorMessage":"Failed to render tauri.conf.json template","messagePattern":"Failed to render tauri\\.conf\\.json template","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/init.rs","lineNumber":266,"sourceCode":"    data.insert(\"dev_url\", to_json(options.dev_url));\n    data.insert(\n      \"app_name\",\n      to_json(options.app_name.as_deref().unwrap_or(\"Tauri App\")),\n    );\n    data.insert(\n      \"window_title\",\n      to_json(options.window_title.as_deref().unwrap_or(\"Tauri\")),\n    );\n    data.insert(\"before_dev_command\", to_json(options.before_dev_command));\n    data.insert(\n      \"before_build_command\",\n      to_json(options.before_build_command),\n    );\n\n    let mut config = serde_json::from_str(\n      &handlebars\n        .render_template(TAURI_CONF_TEMPLATE, &data)\n        .expect(\"Failed to render tauri.conf.json template\"),\n    )\n    .unwrap();\n    if option_env!(\"TARGET\") == Some(\"node\") {\n      let mut dir = current_dir().expect(\"failed to read cwd\");\n      let mut count = 0;\n      let mut cli_node_module_path = None;\n      let cli_path = \"node_modules/@tauri-apps/cli\";\n\n      // only go up three folders max\n      while count <= 2 {\n        let test_path = dir.join(cli_path);\n        if test_path.exists() {\n          let mut node_module_path = PathBuf::from(\"..\");\n          for _ in 0..count {\n            node_module_path.push(\"..\");\n          }\n          node_module_path.push(cli_path);\n          node_module_path.push(\"config.schema.json\");","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/init.rs#L248-L284","documentation":"During `tauri init` the CLI renders the embedded TAURI_CONF_TEMPLATE with the collected options (window title, beforeDevCommand, etc.) and immediately parses the result as JSON. This expect fires if Handlebars reports a render error for that static template. Because both template and data are CLI-controlled, hitting this almost always indicates a broken or corrupted CLI install rather than anything in your project.","triggerScenarios":"Running `tauri init` (or `create-tauri-app` flows that call it) where the embedded template is malformed, the CLI install is corrupted, or option data breaks rendering in that specific CLI build.","commonSituations":"Using an old or nightly CLI version with a template regression; a partially downloaded/corrupted @tauri-apps/cli in node_modules; corrupted cargo install of tauri-cli.","solutions":["Reinstall the CLI package (e.g. `npm i -D @tauri-apps/cli@latest` or `cargo install tauri-cli --locked`) to rule out corruption.","Retry `tauri init` in a fresh empty directory.","Clear the package manager cache (npm cache clean / cargo cache) if reinstall does not help.","If it persists on the latest version, open an issue including the CLI version and the init options used."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Verify the CLI install is intact before init (npm path)\nnpx tauri --version || npm i -D @tauri-apps/cli@latest","typeGuard":null,"tryCatchPattern":"// In scripts: check exit code, panic messages are printed to stderr on non-zero exit\nconst r = spawnSync(\"npx\", [\"tauri\", \"init\", \"--ci\"], { stdio: \"inherit\" });\nif (r.status !== 0) { /* reinstall CLI, clean dir, retry once */ }","preventionTips":["Pin the CLI version in package.json / Cargo.toml so template regressions can't arrive silently.","Warm CI caches with the exact CLI version and checksum-verify installs when possible."],"tags":["rust","tauri-cli","tauri-init","handlebars","tauri-conf-json"],"backgroundTag":"template-render-failed","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}