tauri-apps/tauri · error · Error::GenericError
Could not find a capability to update
Error message
Could not find a capability to update
What it means
After `tauri permission add` collects candidate capabilities, the filtered list is empty. Filtering happens in `filter_map`: files whose extension/content cannot be parsed into a capability are silently dropped, and when `--capability <id>` is passed, only capabilities whose `identifier` field equals that value survive. (Note: for known desktop-only/mobile-only plugins an auto-created capability rescues the empty case, so this error comes from the identifier-filter or unparseable-file path.)
Source
Thrown at crates/tauri-cli/src/acl/permission/add.rs:262
.collect::<Vec<_>>()
.as_slice(),
None,
)?;
if selections.is_empty() {
crate::error::bail!("You did not select any capabilities to update");
}
selections
.into_iter()
.map(|idx| capabilities[idx].clone())
.collect()
} else {
capabilities
};
if capabilities.is_empty() {
crate::error::bail!("Could not find a capability to update");
}
for (capability, path) in &mut capabilities {
if capability.has_permission(&options.identifier) {
log::info!(
"Permission `{}` already found in `{}` at {}",
options.identifier,
capability.identifier(),
dunce::simplified(path).display()
);
} else {
capability.insert_permission(options.identifier.clone());
std::fs::write(&*path, capability.to_string()?)
.fs_context("failed to write capability file", path.clone())?;
log::info!(action = "Added"; "permission `{}` to `{}` at {}", options.identifier, capability.identifier(), dunce::simplified(path).display());
}
}
View on GitHub (pinned to 52e4b6e71d)
Solutions
- List the actual identifiers your project declares: `grep -h '"identifier"' src-tauri/capabilities/*` and pass one of those to `--capability`
- Validate every file in `capabilities/` parses as JSON or TOML and contains a non-empty `identifier` field
- If no capability exists yet, create one (e.g. `tauri capability add` or add `src-tauri/capabilities/default.json` with an `identifier`)
Example fix
// before (src-tauri/capabilities/main.json)
{ "identifier": "main-cap", "windows": ["main"] }
// run: tauri permission add fs:default --capability main <-- no match
// after
tauri permission add fs:default --capability main-cap Defensive patterns
Strategy: validation
Validate before calling
# fail fast if the requested capability identifier does not exist
CAP="$1"
if ! grep -q "\"identifier\"[^A-Za-z0-9_-]*[\"']${CAP}[\"']" src-tauri/capabilities/*; then
echo "capability '$CAP' not declared" >&2; exit 1
fi
tauri permission add my-plugin:default --capability "$CAP" Prevention
- Give every capability file an explicit non-empty `identifier` and reference that exact string
- Validate capability JSON/TOML after hand edits (one wrong file silently drops out of the candidate list)
- In automation, check `grep '"identifier"' capabilities/*` output before invoking the command
When it happens
Trigger: Passing `--capability my-app` when no `capabilities/*.json|toml` file has `"identifier": "my-app"`; or every file in `capabilities/` being invalid (wrong extension, malformed JSON/TOML, missing `identifier`), causing all entries to be dropped by `capability_from_path`.
Common situations: Typos in the capability id; renaming a capability file without updating its `identifier` field; hand-edited capability files with syntax errors; capability files named `.yaml` or with no identifier.
Related errors
- Couldn't find capabilities directory at {}
- You did not select any capabilities to update
- invalid permission {p}
- permission file not found, please build your application onc
- Permission already exists at {}
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/c0a765fc03e64b0d.
Report an issue: GitHub.