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

unexpected list input

Error message

unexpected list input

What it means

A compile-time error from `tauri::generate_context!`. The macro's parser accepts bare paths (Meta::Path) and name-value pairs (Meta::NameValue); list-style syntax like `capabilities = [...]` written as a bare list or `attr(...)` form is rejected with this message.

Solutions

  1. Rewrite the input as name = value pairs: capabilities = ["..."]
  2. Pass the config path as the first plain string argument, then comma-separated key = value options
  3. Remove any parenthesized/bracketed list that is not part of a key = value pair

Example fix

// before
tauri::generate_context!(config("tauri.conf.json"))
// after
tauri::generate_context!("tauri.conf.json")
Defensive patterns

Strategy: validation

Validate before calling

// generate_context! accepts: "config path", key = value pairs, and a bare root path
fn shape_ok(args: &str) -> bool {
  args.starts_with('"') || args.contains("=") || args.chars().all(|c| c.is_alphanumeric() || c == ':' || c == '_')
}

Prevention

When it happens

Trigger: Writing list syntax inside generate_context!, e.g. `generate_context!(foo(a, b))` or passing `capabilities(...)` instead of `capabilities = [...]`.

Common situations: Confusing Rust attribute syntax (#[tauri::command(...)]) with macro-argument syntax; copy-pasting derive-style helper attributes into generate_context!.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

                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")
            .map(|m| PathBuf::from(m).join("tauri.conf.json"))
            .map_err(|e| e.to_string())
        })
        .map_err(|e| input.error(e))?,
      root: root.unwrap_or_else(|| {
        let mut segments = Punctuated::new();
        segments.push(PathSegment {
          ident: Ident::new("tauri", Span::call_site()),

View on GitHub (pinned to 460ec35447)