{"record":{"id":"15e53693131caf34","repo":"tauri-apps/tauri","slug":"failed-to-read-capabilities","errorCode":null,"errorMessage":"failed to read capabilities","messagePattern":"failed to read capabilities","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/context.rs","lineNumber":407,"sourceCode":"        key: #key.into(),\n        crypto_keys: std::boxed::Box::new(::tauri::utils::pattern::isolation::Keys::new().expect(\"unable to generate cryptographically secure keys for Tauri \\\"Isolation\\\" Pattern\")),\n      })\n    }\n  };\n\n  let acl_file_path = out_dir.join(ACL_MANIFESTS_FILE_NAME);\n  let acl: BTreeMap<String, Manifest> = if acl_file_path.exists() {\n    let acl_file =\n      std::fs::read_to_string(acl_file_path).expect(\"failed to read plugin manifest map\");\n    serde_json::from_str(&acl_file).expect(\"failed to parse plugin manifest map\")\n  } else {\n    Default::default()\n  };\n\n  let capabilities_file_path = out_dir.join(CAPABILITIES_FILE_NAME);\n  let capabilities_from_files = if capabilities_file_path.exists() {\n    let capabilities_json =\n      std::fs::read_to_string(&capabilities_file_path).expect(\"failed to read capabilities\");\n    serde_json::from_str(&capabilities_json).expect(\"failed to parse capabilities\")\n  } else {\n    Default::default()\n  };\n  let capabilities = get_capabilities(\n    &config,\n    capabilities_from_files,\n    additional_capabilities.as_deref(),\n  )\n  .unwrap();\n\n  let resolved = Resolved::resolve(&acl, capabilities, target).expect(\"failed to resolve ACL\");\n\n  let acl_tokens = map_lit(\n    quote! { ::std::collections::BTreeMap },\n    &acl,\n    str_lit,\n    identity,","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/context.rs#L389-L425","documentation":"Thrown at build time when the generated capabilities file (CAPABILITIES_FILE_NAME, e.g. capabilities.json) exists in the build output dir but cannot be read with `std::fs::read_to_string`. As with the manifest map, existence was just checked, so failure implies permission problems, a race where the file vanished, or path/type issues.","triggerScenarios":"Running `tauri build`/`tauri dev` when capabilities.json exists in the out dir but is unreadable: ownership/permission mismatch from a prior build as another user, deleted between check and read, or concurrent builds.","commonSituations":"CI runners reusing cached target dirs with different users; concurrent dev/build invocations; antivirus or sync tools locking the file.","solutions":["Delete the stale capabilities file / `cargo clean` and rebuild.","Fix permissions or rebuild as the user that owns the generated files.","Avoid parallel builds sharing one target directory.","Re-run the tauri CLI to regenerate the capabilities file."],"exampleFix":"# before: unreadable generated capabilities file\nrm -f src-tauri/target/*/build/*/out/capabilities.json\ncargo tauri build","handlingStrategy":"validation","validationCode":"const fs = require('fs');\n// pre-build check: generated capabilities file, if present, must be readable\nconst candidates = ['src-tauri/target/dev/build', 'src-tauri/target/release/build'];\nfor (const dir of candidates) {\n  if (!fs.existsSync(dir)) continue;\n  for (const f of findRec(dir, 'capabilities.json')) {\n    try { fs.accessSync(f, fs.constants.R_OK); } catch { console.error(`unreadable: ${f} — delete it or fix permissions`); }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build consistently as one user; clean after switching","Exclude target dirs from antivirus/sync tooling","Avoid concurrent builds into the same target directory","Clean cached target dirs in CI when users differ"],"tags":["build-time","filesystem","file-read","tauri"],"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"}