tauri-apps/tauri · error
failed to read capabilities
Error message
failed to read capabilities
What it means
Build-time panic in tauri-codegen reading OUT_DIR/capabilities.json — the cache of the app's capability files written by tauri-build. std::fs::read_to_string(&capabilities_file_path).expect("failed to read capabilities") fires when the file exists (the exists() check passed) but the read fails: permission loss, deletion or locking between check and read, or non-UTF-8 bytes.
Source
Thrown at crates/tauri-codegen/src/context.rs:405
key: #key.into(),
crypto_keys: std::boxed::Box::new(::tauri::utils::pattern::isolation::Keys::new().expect("unable to generate cryptographically secure keys for Tauri \"Isolation\" Pattern")),
})
}
};
let acl_file_path = out_dir.join(ACL_MANIFESTS_FILE_NAME);
let acl: BTreeMap<String, Manifest> = if acl_file_path.exists() {
let acl_file =
std::fs::read_to_string(acl_file_path).expect("failed to read plugin manifest map");
serde_json::from_str(&acl_file).expect("failed to parse plugin manifest map")
} else {
Default::default()
};
let capabilities_file_path = out_dir.join(CAPABILITIES_FILE_NAME);
let capabilities_from_files = if capabilities_file_path.exists() {
let capabilities_json =
std::fs::read_to_string(&capabilities_file_path).expect("failed to read capabilities");
serde_json::from_str(&capabilities_json).expect("failed to parse capabilities")
} else {
Default::default()
};
let capabilities = get_capabilities(
&config,
capabilities_from_files,
additional_capabilities.as_deref(),
)
.unwrap();
let resolved = Resolved::resolve(&acl, capabilities, target).expect("failed to resolve ACL");
let acl_tokens = map_lit(
quote! { ::std::collections::BTreeMap },
&acl,
str_lit,
identity,View on GitHub (pinned to 52e4b6e71d)
Solutions
- cargo clean and rebuild so capabilities.json is regenerated
- Serialize builds on the same target directory (CI locking, disable rust-analyzer during release builds)
- Fix ownership/permissions of target/ and never mix root/user builds
- Stop external tools (antivirus, indexers, backup) from touching target/
Example fix
# before: panic: failed to read capabilities # after cargo clean && cargo build
Defensive patterns
Strategy: validation
Validate before calling
# remove torn capability caches from interrupted builds before compiling find target -name capabilities.json -size -10c -delete 2>/dev/null || true
Prevention
- Do not edit capability files while a build is running
- Serialize CI builds sharing a target directory
- cargo clean after interrupted builds
When it happens
Trigger: generate_context! reading capabilities.json while a parallel cargo build, antivirus, or cleanup process removes or locks it; target directory shared across users; truncated cache from a build that was killed mid-write.
Common situations: Concurrent CI jobs sharing one target volume; rust-analyzer racing a command-line build; one build step executed as root leaving root-owned artifacts.
Related errors
- Couldn't find capabilities directory at {}
- failed to read plugin manifest map
- failed to parse capabilities
- failed to resolve ACL
- unable to create autogenerated commands dir
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/15e53693131caf34.
Report an issue: GitHub.