tauri-apps/tauri · error

DefaultRuntime requires the last parameter to not have a…

Error message

DefaultRuntime requires the last parameter to not have a default value

What it means

The #[tauri::default_runtime] macro requires the runtime type parameter on the annotated item to have no default value, since the macro itself supplies the default from the given feature/type attributes. If the last generic parameter already carries a default (e.g. `R = Wry`), the macro panics with this message instead of emitting conflicting defaults.

Solutions

  1. Remove the `= Default` from the last generic parameter and let default_runtime supply it
  2. Keep the `Runtime` bound on the parameter but no default
  3. Check the generated item signature via cargo expand after removing the default

Example fix

// before
#[default_runtime]
pub struct App<R: Runtime = Wry> { _r: std::marker::PhantomData<R> }
// after
#[default_runtime]
pub struct App<R: Runtime> { _r: std::marker::PhantomData<R> }
Defensive patterns

Strategy: validation

Validate before calling

// In CI: fail builds if default_runtime items declare default generics
// grep check:
// if rg -U '#\[default_runtime\][\s\S]{0,200}<[^>]*=\s*\w+>' crates/; then exit 1; fi

Prevention

When it happens

Trigger: Writing `pub struct App<R: Runtime = Wry> { ... }` and annotating it with #[default_runtime] (or applying default_runtime to an item whose last generic already has `= SomeType`).

Common situations: Copying a generic struct definition from non-macro code and adding default_runtime; upgrading Tauri and hand-porting runtime generics; IDE auto-inserting a default type parameter.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

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

  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")
    }
  };

  let feature = attributes.feature.to_string();

  quote!(
    #[cfg(feature = #feature)]
    #wry

    #[cfg(not(feature = #feature))]
    #input
  )
}

View on GitHub (pinned to 460ec35447)