tokio-rs/tokio · error · syn::Error
The runtime flavor `multi_thread` requires the `rt-multi-thr
Error message
The runtime flavor `multi_thread` requires the `rt-multi-thread` feature.
What it means
Companion to error 15, this message (entry.rs:213) fires when the user *explicitly* set `flavor = "multi_thread"` but the `rt-multi-thread` feature is disabled. The flavor choice and the enabled feature must agree.
Source
Thrown at tokio-macros/src/entry.rs:213
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,
};
let unhandled_panic = match (flavor, self.unhandled_panic) {View on GitHub (pinned to 625954f365)
Solutions
- Add `rt-multi-thread` to tokio's features in `Cargo.toml`.
- Or change the attribute to `flavor = "current_thread"` if multi-threading is not needed.
Example fix
# before — Cargo.toml
tokio = { version = "1", features = ["macros"] }
// src/main.rs: #[tokio::main(flavor = "multi_thread")] async fn main() {}
# after — Cargo.toml
tokio = { version = "1", features = ["rt-multi-thread", "macros"] } Defensive patterns
Strategy: validation
Prevention
- `flavor = "multi_thread"` requires the `rt-multi-thread` feature.
- Keep the macro flavor and `Cargo.toml` features in sync.
- Use a shared, version-pinned tokio feature list across the workspace.
When it happens
Trigger: Writing `#[tokio::main(flavor = "multi_thread")]` while `Cargo.toml` lists tokio without `rt-multi-thread`.
Common situations: Manually setting flavor to multi-thread on a dependency that was feature-gated down for size; CI using a minimal feature set.
Related errors
- The `worker_threads` option requires the `multi_thread` runt
- The default runtime flavor is `multi_thread`, but the `rt-mu
- The `start_paused` option requires the `current_thread` runt
- The `unhandled_panic` option requires the `current_thread` r
- `name` set multiple times.
AI-assisted analysis of tokio-rs/tokio@625954f365 (2026-08-11).
Data as JSON: /api/errors/ea6d2f63f7a5c632.
Report an issue: GitHub.