Skip to content

Add command to update registry indexΒ #10319

@clarfonthey

Description

@clarfonthey

Problem

The specific case I'm hoping to help for involves running cargo builds in containers. In my case, I'm building system packages for Rust binaries, but I can imagine this being useful for cases like CI as well.

Basically, between builds of the same crate, it's appropriate to cache the results of cargo fetch to avoid downloading every time a build is triggered. However, between builds of different crates, you may not have a specific Cargo.toml to run cargo fetch for, even though the crate index itself still may need to be updated.

It would be useful to be able to run some command that would update the index for a registry (defaulting to crates.io) without having to run some other operation like cargo fetch, so that this command can be run ahead of running any crate-specific operations. In my case, this means I'd be able to share the crates.io cache between builds for crates instead of having to download it every time.

Proposed Solution

Ideally, there would be a command cargo update-index (name doesn't matter too much) that would accept the --registry and --index options from cargo install, but not actually perform anything other than a registry index update. It should work without any options to just update the crates.io index to the default location.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions