Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to update registry index #10319

Closed
clarfonthey opened this issue Jan 23, 2022 · 2 comments
Closed

Add command to update registry index #10319

clarfonthey opened this issue Jan 23, 2022 · 2 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Jan 23, 2022

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

@clarfonthey clarfonthey added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 23, 2022
@weihanglo
Copy link
Member

A workaround is, like you said, using cargo install to install a lib crate. For instance, the following command will fail after updating the registry index (empty-library is preserved by rust-lang):

cargo install empty-library

There is a recent discussion about this topic on Zulip. Read more if you are interested in it:
https://zulip-archive.rust-lang.org/stream/246057-t-cargo/topic/crates.2Eio.20changing.20dl.20url.html'

I myself interpret the thread as "We haven't yet found a way that fits the model Cargo handling sources", but feel free to discuss more further!

@ehuss
Copy link
Contributor

ehuss commented Jan 24, 2022

Yea, unfortunately there are only some poor workarounds for this for now. Closing as a duplicate of #3377.

@ehuss ehuss closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants