tauri-apps/tauri · error
failed to parse capabilities
Error message
failed to parse capabilities
What it means
Build-time panic in tauri-codegen: serde_json::from_str over OUT_DIR/capabilities.json .expect("failed to parse capabilities") fails when the cached capabilities file is invalid JSON or no longer matches the structure the current tauri-codegen expects. The cache is produced by tauri-build from src-tauri/capabilities/*; a mismatch means a corrupt/truncated artifact or a version skew between writer and reader.
Source
Thrown at crates/tauri-codegen/src/context.rs:406
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
- Align Tauri crate versions: `cargo tree -i tauri-utils` / `cargo tree -i tauri-build`, fix duplicates
- Add/modify capability files only while no build is running, then rebuild
- Clear CI build caches keyed on Cargo.lock after any Tauri dependency change
Example fix
# before: panic: failed to parse capabilities # after cargo clean && cargo build
Defensive patterns
Strategy: validation
Validate before calling
# validate the capability cache parses before the codegen step runs
python3 -c "import json;json.load(open('target/debug/build'))" 2>/dev/null || cargo clean Prevention
- Clean the target directory after Tauri upgrades
- Verify a single tauri-utils version in the dependency graph (cargo tree -i tauri-utils)
- Never hand-edit generated files under target/
When it happens
Trigger: Building after a Tauri upgrade with a stale capabilities.json in OUT_DIR; a build interrupted while writing the file; mixed tauri crate versions in one workspace producing schema drift.
Common situations: Tauri minor upgrade without cleaning target; CI cache reuse of target across version bumps; editing capabilities while a build runs, leaving a torn cache.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse plugin manifest map
- failed to read capabilities
- failed to resolve ACL
- Couldn't find capabilities directory at {}
- You did not select any capabilities to update
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/5ce03dc451ad07d7.
Report an issue: GitHub.