{"record":{"id":"5d66303b87b52e2f","repo":"tauri-apps/tauri","slug":"failed-to-canonicalize-tauri-global-api-script-path","errorCode":null,"errorMessage":"failed to canonicalize tauri global API script path","messagePattern":"failed to canonicalize tauri global API script path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri/build.rs","lineNumber":347,"sourceCode":"\n    let lib_path =\n      PathBuf::from(std::env::var_os(\"CARGO_MANIFEST_DIR\").unwrap()).join(\"mobile/android\");\n    println!(\"cargo:android_library_path={}\", lib_path.display());\n  }\n\n  #[cfg(target_os = \"macos\")]\n  {\n    if target_os == \"ios\" {\n      let lib_path =\n        PathBuf::from(std::env::var_os(\"CARGO_MANIFEST_DIR\").unwrap()).join(\"mobile/ios-api\");\n      tauri_utils::build::link_apple_library(\"Tauri\", &lib_path);\n      println!(\"cargo:ios_library_path={}\", lib_path.display());\n    }\n  }\n\n  let tauri_global_scripts = PathBuf::from(\"./scripts/bundle.global.js\")\n    .canonicalize()\n    .expect(\"failed to canonicalize tauri global API script path\");\n  tauri_utils::plugin::define_global_api_script_path(&tauri_global_scripts);\n  // This should usually be done in `tauri-build`,\n  // but we need to do this here for the examples in this workspace to work as they don't have build scripts\n  if is_tauri_workspace {\n    tauri_utils::plugin::save_global_api_scripts_paths(&out_dir, Some(tauri_global_scripts));\n  }\n\n  let permissions = define_permissions(&out_dir);\n  tauri_utils::acl::build::generate_allowed_commands(&out_dir, None, permissions).unwrap();\n}\n\nconst LICENSE_HEADER: &str = r\"# Copyright 2019-2024 Tauri Programme within The Commons Conservancy\n# SPDX-License-Identifier: Apache-2.0\n# SPDX-License-Identifier: MIT\n\";\n\nfn define_permissions(\n  out_dir: &Path,","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/build.rs#L329-L365","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-clone or restore the tauri checkout so crates/tauri/scripts/bundle.global.js exists","Run the repo's script bundling step (pnpm build / build scripts) if building tauri from source","Build tauri from a crates.io release instead of a partial source checkout","Ensure the build script's cwd is the crate root (cargo guarantees this; don't override it)"],"exampleFix":"// before\ncurl -L https://github.com/tauri-apps/tauri/archive/refs/heads/dev.tar.gz | tar xz && cargo build\n// after\ngit clone https://github.com/tauri-apps/tauri.git && cd tauri && pnpm install && pnpm build && cargo build","handlingStrategy":"validation","validationCode":"let script = std::path::Path::new(\"crates/tauri/scripts/bundle.global.js\");\nassert!(script.is_file(), \"bundle.global.js missing; run the repo's build/bundle step first\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When building tauri from source, always run `pnpm install && pnpm build` first","Prefer crates.io releases over hand-assembled source trees","Run cargo from the workspace root"],"tags":["build-script","filesystem","missing-file"],"backgroundTag":"file-not-found","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"}