tokio-rs/tokio · error · syn::Error

The default runtime flavor is `multi_thread`, but the `rt-mu

Error message

The default runtime flavor is `multi_thread`, but the `rt-multi-thread` feature is disabled.

What it means

In `build` (entry.rs:210), when the flavor resolves to `Threaded` but the `rt-multi-thread` Cargo feature is *not* enabled, the macro errors. This specific message fires when the user did *not* set `flavor` explicitly, so the default (`multi_thread`) was chosen — but the feature backing it is off.

Source

Thrown at tokio-macros/src/entry.rs:211

        use RuntimeFlavor as F;

        let flavor = self.flavor.unwrap_or(self.default_flavor);

        let worker_threads = match (flavor, self.worker_threads) {
            (F::CurrentThread | F::Local, Some((_, worker_threads_span))) => {
                let msg = format!(
                    "The `worker_threads` option requires the `multi_thread` runtime flavor. Use `#[{}(flavor = \"multi_thread\")]`",
                    self.macro_name(),
                );
                return Err(syn::Error::new(worker_threads_span, msg));
            }
            (F::CurrentThread | F::Local, None) => None,
            (F::Threaded, worker_threads) if self.rt_multi_thread_available => {
                worker_threads.map(|(val, _span)| val)
            }
            (F::Threaded, _) => {
                let msg = if self.flavor.is_none() {
                    "The default runtime flavor is `multi_thread`, but the `rt-multi-thread` feature is disabled."
                } else {
                    "The runtime flavor `multi_thread` requires the `rt-multi-thread` feature."
                };
                return Err(syn::Error::new(Span::call_site(), msg));
            }
        };

        let start_paused = match (flavor, self.start_paused) {
            (F::Threaded, Some((_, start_paused_span))) => {
                let msg = format!(
                    "The `start_paused` option requires the `current_thread` runtime flavor. Use `#[{}(flavor = \"current_thread\")]`",
                    self.macro_name(),
                );
                return Err(syn::Error::new(start_paused_span, msg));
            }
            (F::CurrentThread | F::Local, Some((start_paused, _))) => Some(start_paused),
            (_, None) => None,
        };

View on GitHub (pinned to 625954f365)

Solutions

  1. Enable the feature: `tokio = { version = "1", features = ["rt-multi-thread", "macros"] }`.
  2. Or opt into the single-threaded default explicitly: `#[tokio::main(flavor = "current_thread")]` (requires the `rt` feature).

Example fix

# before — Cargo.toml
tokio = { version = "1", features = ["macros"] }

# after — Cargo.toml
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Depending on tokio without the `rt-multi-thread` feature (e.g. only `features = ["rt", "macros"]`) while relying on the default `#[tokio::main]` flavor.

Common situations: Trimming tokio features for binary size; copy-pasting a dependency line that omits `rt-multi-thread`; new projects using the macro without enabling the full runtime.

Related errors


AI-assisted analysis of tokio-rs/tokio@625954f365 (2026-08-11). Data as JSON: /api/errors/68ddeac24a4c0198. Report an issue: GitHub.