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

  1. List the actual identifiers your project declares: `grep -h '"identifier"' src-tauri/capabilities/*` and pass one of those to `--capability`
  2. Validate every file in `capabilities/` parses as JSON or TOML and contains a non-empty `identifier` field
  3. 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

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


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/c0a765fc03e64b0d. Report an issue: GitHub.