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

unknown attribute {name}

Error message

unknown attribute {name}

What it means

#[tauri::generate_context] has a fixed vocabulary: an optional leading string literal (the config file path), then the keys capabilities, assets and test. Any other name=value key falls into the catch-all arm and the macro stops with `unknown attribute {name}`, echoing the offending key so the typo is obvious.

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 52e4b6e71d)

Solutions

  1. Pass the config path as the first bare argument: #[tauri::generate_context("tauri.conf.json")] or with no argument for the default lookup
  2. Limit keys to capabilities, assets and test
  3. Match examples to the exact tauri/tauri-macros version pinned in Cargo.lock

Example fix

// before
#[tauri::generate_context(config = "tauri.conf.json")]
// after
#[tauri::generate_context("tauri.conf.json")]
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: #[tauri::generate_context(config = "tauri.conf.json")] — the config path is written as a bare leading string literal, not a config = key; also invented keys like env, mode, source, or misspellings such as capability.

Common situations: Assuming a key=value API for the config path; following outdated blog posts or examples from a different tauri version; IDE completion suggesting keys that do not exist.

Related errors


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