{"record":{"id":"8be3bf24c68ec546","repo":"tauri-apps/tauri","slug":"failed-to-read-plugin-global-api-script-e","errorCode":null,"errorMessage":"failed to read plugin global API script {}: {e}","messagePattern":"failed to read plugin global API script (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/plugin.rs","lineNumber":79,"sourceCode":"\n  /// Read global api scripts from [`GLOBAL_API_SCRIPT_FILE_LIST_PATH`]\n  pub fn read_global_api_scripts(out_dir: &Path) -> Option<Vec<String>> {\n    let global_scripts_path = out_dir.join(GLOBAL_API_SCRIPT_FILE_LIST_PATH);\n    if !global_scripts_path.exists() {\n      return None;\n    }\n\n    let global_scripts_str = fs::read_to_string(global_scripts_path)\n      .expect(\"failed to read plugin global API script paths\");\n    let global_scripts = serde_json::from_str::<Vec<PathBuf>>(&global_scripts_str)\n      .expect(\"failed to parse plugin global API script paths\");\n\n    Some(\n      global_scripts\n        .into_iter()\n        .map(|p| {\n          fs::read_to_string(&p).unwrap_or_else(|e| {\n            panic!(\n              \"failed to read plugin global API script {}: {e}\",\n              p.display()\n            )\n          })\n        })\n        .collect(),\n    )\n  }\n}\n","sourceCodeStart":61,"sourceCodeEnd":89,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/plugin.rs#L61-L89","documentation":"`read_global_api_scripts` reads each path from a plugin's `global-api-script` build output so the scripts can be injected into every webview. If any listed script file cannot be read from disk, the build/runtime panics. The file was registered (usually via build script output) but is missing or unreadable.","triggerScenarios":"A plugin declared a global API script path (via `tauri_build::InlinedPlugin` / build script stdout `global-api-script` lines) but `fs::read_to_string` fails at read time — file deleted, moved, or never generated.","commonSituations":"Stale cargo build caches pointing at removed target-dir files; a plugin's build script skipped generation (feature disabled) while the path was still emitted; permission problems on the file.","solutions":["Run `cargo clean` (or clean the affected plugin) and rebuild so the plugin's build script regenerates the global API script.","Verify the plugin in the message supports/enables the feature that emits its global API script and re-add/install it correctly.","Check the file exists and is readable at the path printed in the message; fix permissions if needed.","Update the plugin and tauri crates to matching versions, since script path handling changed across versions."],"exampleFix":"// before: stale path cached\ncargo build // panics reading target/.../global-script.js\n// after\ncargo clean && cargo build","handlingStrategy":"validation","validationCode":"// verify plugin global api scripts exist before build\nconst fs = require('fs');\nconst exists = (p) => fs.existsSync(p) && fs.statSync(p).isFile();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run cargo clean when plugin script paths go stale after upgrades","Install plugins via cargo/cargo-tauri rather than copying build outputs manually","Check that plugin features emitting global API scripts are enabled in your Cargo features"],"tags":["filesystem","plugins","build","panic"],"backgroundTag":"file-read-failed","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"}