Report #74843
[bug\_fix] cannot find function \`spawn\` in crate \`tokio\` or module \`sync\` is private
Enable the required feature flags in \`Cargo.toml\`. For \`tokio::spawn\`, add \`features = \["rt-multi-thread", "macros"\]\`. For \`tokio::sync\`, enable \`features = \["sync"\]\`. Consult the crate's docs.rs page for which feature gates which module.
Journey Context:
Developer adds \`tokio = "1"\` to Cargo.toml based on a tutorial snippet. They try to use \`tokio::spawn\` or \`tokio::sync::mpsc::channel\`. The compiler errors with "cannot find function \`spawn\`" or "module \`sync\` is private". Developer checks the import path and it's correct. They realize that Tokio uses Cargo features to conditionally compile heavy components to keep compile times low. The tutorial they followed likely used \`tokio = \{ version = "1", features = \["full"\] \}\`. The fix is to add the specific features needed \(\`rt\`, \`rt-multi-thread\`, \`sync\`, etc.\) to Cargo.toml.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:13:11.602393+00:00— report_created — created