tauri-apps/tauri · error

Failed to render tauri.conf.json template

Error message

Failed to render tauri.conf.json template

What it means

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.

Source

Thrown at crates/tauri-cli/src/init.rs:266

    data.insert("dev_url", to_json(options.dev_url));
    data.insert(
      "app_name",
      to_json(options.app_name.as_deref().unwrap_or("Tauri App")),
    );
    data.insert(
      "window_title",
      to_json(options.window_title.as_deref().unwrap_or("Tauri")),
    );
    data.insert("before_dev_command", to_json(options.before_dev_command));
    data.insert(
      "before_build_command",
      to_json(options.before_build_command),
    );

    let mut config = serde_json::from_str(
      &handlebars
        .render_template(TAURI_CONF_TEMPLATE, &data)
        .expect("Failed to render tauri.conf.json template"),
    )
    .unwrap();
    if option_env!("TARGET") == Some("node") {
      let mut dir = current_dir().expect("failed to read cwd");
      let mut count = 0;
      let mut cli_node_module_path = None;
      let cli_path = "node_modules/@tauri-apps/cli";

      // only go up three folders max
      while count <= 2 {
        let test_path = dir.join(cli_path);
        if test_path.exists() {
          let mut node_module_path = PathBuf::from("..");
          for _ in 0..count {
            node_module_path.push("..");
          }
          node_module_path.push(cli_path);
          node_module_path.push("config.schema.json");

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Reinstall the CLI package (e.g. `npm i -D @tauri-apps/cli@latest` or `cargo install tauri-cli --locked`) to rule out corruption.
  2. Retry `tauri init` in a fresh empty directory.
  3. Clear the package manager cache (npm cache clean / cargo cache) if reinstall does not help.
  4. If it persists on the latest version, open an issue including the CLI version and the init options used.
Defensive patterns

Strategy: validation

Validate before calling

# Verify the CLI install is intact before init (npm path)
npx tauri --version || npm i -D @tauri-apps/cli@latest

Try / catch

// In scripts: check exit code, panic messages are printed to stderr on non-zero exit
const r = spawnSync("npx", ["tauri", "init", "--ci"], { stdio: "inherit" });
if (r.status !== 0) { /* reinstall CLI, clean dir, retry once */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/b7d1768227f6b008. Report an issue: GitHub.