Why does cargo translate a package wrongly when adding?

Hello!

I have dozens of packages inside this one folder. I am trying to add criterion to the project so I add it per the command but cargo for whatever reason translates the package to "prodash" which is obviously nowhere similar to criterion. If I delete prodash, it translates it to something different. However, if I add criterion by using the specific version in the naming it works.

Why is that? I have scoured the internet and any documents I could find and there's no solution aside from specific version naming.

Thank you!

I've been using Rust since before Cargo existed, and I have no idea what you're talking about. I'm not aware of any sort of "translation" behaviour in Cargo.

I recommend that you give as much information as possible on exactly what you are doing. What does the folder structure look like? Exactly what commands are you running? Where are you running them? What is the output of Cargo? How does the manifest change?

7 Likes

My first suggestion would be to delete the following:

  • Your crate cache in .cargo/registry/.
  • Your target directory.
  • Your Cargo.lock file.

It sounds like your issue is some sort of corruption in the crate cache, and clearing the above files should hopefully eliminate the problem.

1 Like

I have to say I am pretty baffled myself as I haven't encountered this before and I can't find much information online.

The folders present are: .cargo, src, target, vendor. Vendor keeping all the libraries needed for compilation in a machine without a connection.

The command that is used is simply cargo add criterion which is run in the command prompt. The response is:

> cargo add criterion
warning: translating `criterion` to `prodash`
Adding prodash v23.1.2 to dependencies.

The only thing that changes in the manifest is adding prodash as a dependency like it says.

Okay, let's establish some common ground. I just did this:

F:\Programming\Rust\sandbox\urlo\t102167>cargo init . --bin --name wtf
     Created binary (application) package

F:\Programming\Rust\sandbox\urlo\t102167>type Cargo.toml
[package]
name = "wtf"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

F:\Programming\Rust\sandbox\urlo\t102167>cargo add criterion
    Updating crates.io index
      Adding criterion v0.5.1 to dependencies.
             Features:
             + cargo_bench_support
             + plotters
             + rayon
             - async
             - async-std
             - async_futures
             - async_smol
             - async_std
             - async_tokio
             - csv
             - csv_output
             - futures
             - html_reports
             - real_blackbox
             - smol
             - stable
             - tokio
    Updating crates.io index

F:\Programming\Rust\sandbox\urlo\t102167>type Cargo.toml
[package]
name = "wtf"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
criterion = "0.5.1"

F:\Programming\Rust\sandbox\urlo\t102167>

So this behaviour is not a thing that's supposed to happen.

You have both a .cargo and vendor. The only thing that comes to mind is that you have configured cargo to not use the public crates.io for resolving dependencies, that is preventing it from finding criterion and is instead substituting prodash (because prodash depends on criterion?).

My first instinct would be to (temporarily) ditch .cargo and vendor, along with anything to restrict cargo and see if it still happens. If it doesn't, then it's something about how you're restricting cargo, and you should probably post how you've configured cargo for scrutiny.

To be clear, I've never done anything with vendoring or restricting cargo, so I doubt I can be much direct help with this.

Edit: tiny bit of extra detail: this error message appears to occur in only two places in Cargo, with the likely culprit being a warning that the crate name you asked for doesn't match the selected crate's name. That itself is based on the result of select_package, so it does seem like for some reason Cargo is getting very confused as to what crate it's supposed to be finding.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.