tauri-apps/tauri · error

default_runtime requires the item to have at least 1…

Error message

default_runtime requires the item to have at least 1 generic parameter

What it means

The `#[default_runtime]` attribute macro in tauri-macros rewrites the last generic parameter of the annotated item to default to the configured runtime type (e.g. `Wry`). It panics when the item has no generic parameters at all, because there is nothing to rewrite.

Solutions

  1. Add at least one generic type parameter (conventionally `R: Runtime`) to the annotated item.
  2. Ensure the generic is the LAST parameter so `last_param_mut` targets it.
  3. Remove the `#[default_runtime]` attribute if the item genuinely should not be runtime-generic.

Example fix

// before
#[default_runtime(Wry)]
struct MyPlugin;

// after
#[default_runtime(Wry)]
struct MyPlugin<R: Runtime> { /* uses R */ }
Defensive patterns

Strategy: validation

Validate before calling

// compile-time check: item must be generic over the runtime
fn assert_generic<R: tauri::Runtime>() {}
assert_generic::<tauri::Wry>(); // fails to compile if the type has no runtime generic

Prevention

When it happens

Trigger: Applying `#[default_runtime(...)]` (directly or via `#[tauri::command]`-style wrappers that use it) to a struct/enum/type alias with zero generic parameters, or an item whose last generic is a lifetime/const rather than a type parameter.

Common situations: Hand-writing internal Tauri types without the `R: Runtime` generic after a copy-paste, or upgrading Tauri and defining a custom runtime-related type that previously had generics removed.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at crates/tauri-macros/src/runtime.rs:77

}

impl Parse for Attributes {
  fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
    let default_type = input.parse()?;
    input.parse::<Token![,]>()?;
    Ok(Attributes {
      default_type,
      feature: input.parse()?,
    })
  }
}

pub(crate) fn default_runtime(attributes: Attributes, input: Input) -> TokenStream {
  // create a new copy to manipulate for the wry feature flag
  let mut wry = input.clone();
  let wry_runtime = wry
    .last_param_mut()
    .expect("default_runtime requires the item to have at least 1 generic parameter");

  // set the default value of the last generic parameter to the provided runtime type
  match wry_runtime {
    GenericParam::Type(
      param @ TypeParam {
        eq_token: None,
        default: None,
        ..
      },
    ) => {
      param.eq_token = Some(parse_quote!(=));
      param.default = Some(attributes.default_type);
    }
    _ => {
      panic!("DefaultRuntime requires the last parameter to not have a default value")
    }
  };

View on GitHub (pinned to 460ec35447)