Skip to content

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

Open
@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 init foo           
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cd foo        

$ cargo add rayon       
    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

$ cargo update -p rayon --precise 1.13.0
    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

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions