cargo-edit icon indicating copy to clipboard operation
cargo-edit copied to clipboard

cargo upgrade gets stuck when using sparse registry protocol

Open amsam0 opened this issue 2 years ago • 2 comments

Hi, running cargo upgrade gets stuck when using the sparse registry protocol. (It may be cloning the entire registry, but I'd rather not wait to find out)

The issue is caused here: https://github.com/killercup/cargo-edit/blob/master/src/fetch.rs#L322 cargo-edit uses 0.x of crates-index, which only supports the git registry protocol.

To fix this, all that's needed is to upgrade crates-index to the latest version (2.x) and then detect the registry protocol and use the corresponding Index struct in crates-index.

Some of crates-index's features will need to be enabled: https://docs.rs/crates-index/latest/crates_index/index.html#feature-flags To determine the struct to use, we need to get the value of this config option: https://doc.rust-lang.org/cargo/reference/config.html#registriescrates-ioprotocol If the protocol is sparse, this struct should be used: https://docs.rs/crates-index/latest/crates_index/struct.SparseIndex.html If the protocol is git, this struct should be used: https://docs.rs/crates-index/latest/crates_index/struct.GitIndex.html

amsam0 avatar Aug 08 '23 21:08 amsam0

Anyone have a recommended workaround for now?

coriolinus avatar Jun 14 '24 09:06 coriolinus

I believe cargo +nightly -Zunstable-options update --breaking should be in the latest nightly.

epage avatar Jun 14 '24 11:06 epage

Based on https://github.com/rust-lang/cargo/issues/14204 it seems that cargo update --breaking is in fact not meant to be a replacement for cargo upgrade and there is no plan to support that either.

VorpalBlade avatar Jul 06 '24 21:07 VorpalBlade

That's unfortunate. cargo upgrade was quite useful.

Never expected to find myself on this side of https://xkcd.com/1172/.

coriolinus avatar Jul 06 '24 23:07 coriolinus

From another issue they posted on

It is the replacement we are offering. It is not a direct port but what we found works for integrating into cargo.

If people have feedback on the design, the place to do it is on the primary issue for --breaking. Please read the first couple of comments from me on it so your feedback can be in reply to them rather than retreading existing ground.

epage avatar Jul 06 '24 23:07 epage