Report #6291
[bug\_fix] failed to select a version for the requirement \`crate = "^X.Y"\`
Run \`cargo update -p \` to refresh the Cargo.lock, or manually edit \`Cargo.toml\` to use compatible version specifications. If using Rust 2018 edition, add \`resolver = "2"\` to the \`\[package\]\` section to prevent dev-dependency features from leaking into normal builds. Root cause: Cargo's SAT-based resolver cannot find a set of package versions satisfying all constraints, often due to two crates depending on incompatible semver ranges of a shared transitive dependency, or feature unification issues.
Journey Context:
Developer adds \`tokio-util\` to a project that already uses \`tokio\` 1.0. The build fails with "failed to select a version for \`tokio\`. required by package \`tokio-util\`... found 1.0.0, but another package requires tokio ^0.2". The developer examines \`Cargo.toml\` and sees only one tokio entry. They run \`cargo tree\` and discover that an old crate \`legacy-crate\` depends on \`tokio 0.2\`. They attempt to update \`legacy-crate\` but it's unmaintained. They consider forking but instead discover \`cargo update --precise\` or using \`\[patch\]\` to override. However, the real fix is realizing they need to upgrade the intermediate crate or use compatibility shims. In another scenario, the developer finds that enabling a feature in a dev-dependency \(like \`tokio/full\`\) causes it to be enabled in normal builds, leading to compilation errors in dependencies that expect minimal features. They learn about \`resolver = "2"\` introduced in Rust 2021 which isolates feature sets for host vs target dependencies, fixing the unification issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:43:33.965784+00:00— report_created — created