[rust/cargo registry] cargo publish creates an invalid index entry

Hello,

I have a problem regarding the cargo registry on the Nexus I deployed.
When trying to publish a crate to it, it pushes a broken index.

Cargo error when trying to fetch said crate :

Failed to select a version for the requirement `d = “x.y.z”`
Version x.y.z’s index entry is invalid

I believe this is somewhat related to this issue, because this message only appears when:

  • A package has been renamed in the Cargo.toml
    • example:
[dependencies]
renamed = {package = “original-name”, version=”*”, optional = true}
  • AND a feature needs this package
    • example:
[features]
f = [“renamed”]

according to the registry web api docs, we can provide for ach dependency a field explicit_name_in_toml.

When the field is provided, the name property in the index should be this explicit_name_in_toml, and the package property of this dependency in the index should be the real name of the dependency.

However, I can not get the nexus registry index to have the package entry for a dependency in that case.


I’ve also tried brute forcing it to verify it was not a cargo error, with a python script that sends a PUT request to the registry’s api/v1/crates/new route with the correct format (json length + json content + tarball length + tarball).
Even when explicitly setting the explicit_name_in_toml, the package property is not present in the created index entry.


I would have loved to help and pinpoint the problem in the registry source code but the nexus cargo registry is closed-source (if I’m not mistaken).

This might make more sense to be created as an issue - GitHub · Where software is built

Possibly an alternative suggestion - have you tried a group repository which also contains a proxy?

cargo-group
 - cargo-hosted
 - cargo-proxy

From your description this might resolve the issue as the dependencies and the hosted content would externally appear to be from the same source.