Skip to content

Include registry names in cargo metadata output #9052

@sunshowers

Description

@sunshowers

Describe the problem you are trying to solve
For some automated tooling built on top of guppy, I'd like to be able to reconstruct Cargo.toml dependency lines from cargo metadata output. This is possible to do for crates.io, path and Git dependencies, but doesn't appear to be possible to do for non-default registries.

Specifically, the bit that's missing is the name of the registry. The output format has a "registry" field in the dependencies section, but that contains the URL and not the name. The URL cannot be specified in Cargo.toml's registry field -- it must be a name.

Describe the solution you'd like
There's a few ways to do this, but I think the cleanest way would be to add a new top-level section to cargo metadata output, say registries, which has:

  • the default registry along with its URL (typically crates.io but could be something else)
  • any other registries in use along with their URLs.
  • possibly other details about each registry?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-registriesArea: registriesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-metadataS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions