rust-lang / rust-lang/cargo

maybe suggest running `cargo update` if there's a previously selected version conflict

Open
#5,484 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-dependency-resolution A-diagnostics S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

I added a new dependency to a project, ran cargo build and got this:

    error: failed to select a version for `libc`
    all possible versions conflict with previously selected versions of `libc`
    required by package `dlopen_derive v0.1.0`
        ... which is depended on by `dlopen v0.1.0`
        ... which is depended on by `ooppkcs11rs v0.0.1 (file:///home/keeler/src/ooppkcs11rs)`
      previously selected package `libc v0.2.23`
        ... which is depended on by `ipc-channel v0.10.0`
        ... which is depended on by `ooppkcs11rs v0.0.1 (file:///home/keeler/src/ooppkcs11rs)`
      possible versions to select: 0.2.40, 0.2.39, 0.2.38, 0.2.37, 0.2.36, 0.2.35, 0.2.34, 0.2.33, 0.2.32, 0.2.31, 0.2.30, 0.2.29 

My assumption was this was because ipc-channel didn't support libc >0.2.23, but there's no such restriction in ipc-channel's Cargo.toml, so this was just confusing. I ended up removing Cargo.lock and rebuilding, and this worked. A colleague later told me cargo update is the real way to fix this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the dependency conflict with cargo build, then trace the Cargo entry point that formats this version-selection error. Check how Cargo.lock and cargo update are handled in the existing user guidance, and verify that the completed change explains the recovery path without misleading users.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.