Skip to content
Latchkey

cargo "failed to select a version for the requirement" in CI

cargo resolved your dependency graph and could not find a single version of a crate that satisfies every requirement at once. The message names the crate and the conflicting requirements that left no candidate.

What this error means

cargo build or cargo update stops with "error: failed to select a version for the requirement X = ..." followed by "candidate versions found which didn't match" and the constraints that collide.

cargo
error: failed to select a version for the requirement `time = "^0.1"`
candidate versions found which didn't match: 0.3.36, 0.3.35, ...
location searched: crates.io index
required by package `chrono v0.4.38`

Common causes

Two crates require non-overlapping version ranges

One dependency requires time ^0.1 while another transitively needs time ^0.3. No published version is in both ranges, so the resolver gives up.

A direct pin is older than what a transitive dep needs

A hard requirement in your Cargo.toml caps a crate below the version a newer dependency now demands.

How to fix it

Read the requirements and loosen or upgrade

  1. Read which package is "required by" each conflicting requirement.
  2. Upgrade the crate holding the lower cap to a release that accepts the needed range.
  3. Run cargo update -p <crate> and re-resolve.
Terminal
cargo update -p chrono --precise 0.4.38
cargo build

Widen an over-tight direct requirement

If your own Cargo.toml pins too narrowly, broaden it to a range that overlaps what transitive crates require.

Cargo.toml
[dependencies]
time = ">=0.3, <0.4"

How to prevent it

  • Commit Cargo.lock so the resolved set is reused, not recomputed each run.
  • Prefer ranges over exact pins in your own dependencies.
  • Upgrade related crates together so shared ranges stay compatible.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →