Skip to content

Confusing error 'no matching package' on bad version #15015

@Wilfred

Description

@Wilfred

Problem

When given an invalid version for a package that exists, Cargo produces the following error:

error: no matching package named `rayon` found

This is confusing, as it makes it sound like the package name is incorrect, rather than the version.

Steps

$ cargo new cargo-15015 && cd cargo-15015 && cargo add rayon && cargo update -p rayon --precise 1.13.0
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    Updating crates.io index
      Adding rayon v1.10.0 to dependencies
             Features:
             - web_spin_lock
    Updating crates.io index
     Locking 6 packages to latest compatible versions
    Updating crates.io index
error: no matching package named `rayon` found
location searched: registry `crates-io`
required by package `foo v0.1.0 (/home/wilfred/tmp/foo)`

Possible Solution(s)

The error message would ideally mention the package version being a problem.

Version

$ cargo --version                       
cargo 1.83.0 (5ffbef321 2024-10-29)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverA-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions