tauri-apps/tauri · error · syn::Error

unknown attribute

Error message

unknown attribute {name}

What it means

A compile-time error from `tauri::generate_context!`. The macro only recognizes the name-value attributes `capabilities`, `assets`, and `test` (plus a bare path for the root and a leading config file string). Any other attribute name aborts compilation with this message naming the offending attribute.

Solutions

  1. Fix the attribute spelling; only capabilities, assets, and test are supported
  2. Remove the attribute and set the equivalent option in tauri.conf.json
  3. Check the Tauri version's generate_context! documentation for supported options

Example fix

// before
tauri::generate_context!("tauri.conf.json", capabilites = ["default"])
// after
tauri::generate_context!("tauri.conf.json", capabilities = ["default"])
Defensive patterns

Strategy: validation

Validate before calling

// Only these macro attribute names are accepted
const ALLOWED: &[&str] = &["capabilities", "assets", "test"];
assert!(ALLOWED.contains(&ATTR_NAME), "unsupported generate_context! attribute");

Prevention

When it happens

Trigger: Passing an unsupported key like `config = ...`, `dev = ...`, or a misspelled `capabilites = [...]` inside `generate_context!`.

Common situations: Typos in attribute names; confusing generate_context! options with tauri.conf.json fields; using options from an older or newer Tauri version.

Understand the failure class

Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/4632a85556bd55b6. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri-macros/src/context.rs:110

                ));
              }
            }
            "assets" => {
              assets.replace(v.value);
            }
            "test" => {
              if let Expr::Lit(ExprLit {
                lit: Lit::Bool(LitBool { value, .. }),
                ..
              }) = v.value
              {
                test = value;
              } else {
                return Err(syn::Error::new(input.span(), "unexpected value for test"));
              }
            }
            name => {
              return Err(syn::Error::new(
                input.span(),
                format!("unknown attribute {name}"),
              ));
            }
          }
        }
        Meta::List(_) => {
          return Err(syn::Error::new(input.span(), "unexpected list input"));
        }
      }

      let _ = input.parse::<Token![,]>();
    }

    Ok(Self {
      config_file: config_file
        .unwrap_or_else(|| {
          std::env::var("CARGO_MANIFEST_DIR")

View on GitHub (pinned to 460ec35447)