tauri-apps/tauri · error

failed to canonicalize tauri global API script path

Error message

failed to canonicalize tauri global API script path

What it means

Build-script panic when Path::canonicalize fails on ./scripts/bundle.global.js, the prebuilt Tauri global API script. canonicalize resolves the path to an absolute path and fails if the file does not exist or the path cannot be resolved; the resolved path is then registered via define_global_api_script_path for use by plugins/examples.

Solutions

  1. Re-clone or restore the tauri checkout so crates/tauri/scripts/bundle.global.js exists
  2. Run the repo's script bundling step (pnpm build / build scripts) if building tauri from source
  3. Build tauri from a crates.io release instead of a partial source checkout
  4. Ensure the build script's cwd is the crate root (cargo guarantees this; don't override it)

Example fix

// before
curl -L https://github.com/tauri-apps/tauri/archive/refs/heads/dev.tar.gz | tar xz && cargo build
// after
git clone https://github.com/tauri-apps/tauri.git && cd tauri && pnpm install && pnpm build && cargo build
Defensive patterns

Strategy: validation

Validate before calling

let script = std::path::Path::new("crates/tauri/scripts/bundle.global.js");
assert!(script.is_file(), "bundle.global.js missing; run the repo's build/bundle step first");

Prevention

When it happens

Trigger: Building the tauri crate from its source when crates/tauri/scripts/bundle.global.js is missing (script not built yet, incomplete checkout, or the crate was packaged without the generated script), or the current working directory is not the crate root.

Common situations: Building tauri from a GitHub tarball that excluded generated files, running cargo build from the wrong directory with a relative path configuration, or a corrupted/partial clone of the tauri repository.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/5d66303b87b52e2f. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri/build.rs:347

    let lib_path =
      PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("mobile/android");
    println!("cargo:android_library_path={}", lib_path.display());
  }

  #[cfg(target_os = "macos")]
  {
    if target_os == "ios" {
      let lib_path =
        PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("mobile/ios-api");
      tauri_utils::build::link_apple_library("Tauri", &lib_path);
      println!("cargo:ios_library_path={}", lib_path.display());
    }
  }

  let tauri_global_scripts = PathBuf::from("./scripts/bundle.global.js")
    .canonicalize()
    .expect("failed to canonicalize tauri global API script path");
  tauri_utils::plugin::define_global_api_script_path(&tauri_global_scripts);
  // This should usually be done in `tauri-build`,
  // but we need to do this here for the examples in this workspace to work as they don't have build scripts
  if is_tauri_workspace {
    tauri_utils::plugin::save_global_api_scripts_paths(&out_dir, Some(tauri_global_scripts));
  }

  let permissions = define_permissions(&out_dir);
  tauri_utils::acl::build::generate_allowed_commands(&out_dir, None, permissions).unwrap();
}

const LICENSE_HEADER: &str = r"# Copyright 2019-2024 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT
";

fn define_permissions(
  out_dir: &Path,

View on GitHub (pinned to 460ec35447)