cargo uninstall with a sparse registry removes "sparse+" from the urls in .cargo.toml and .cargo2.json breaking install/uninstall #11751
Labels
A-sparse-registry
Area: http sparse registries
C-bug
Category: bug
Command-uninstall
P-high
Priority: High
regression-from-stable-to-beta
Regression in beta that previously worked in stable.
Problem
When running "cargo uninstall" the "sparse" prefix is removed from the urls in .crates.toml and .crates2.json files. Breaking the file and stopping cargo install/uninstall from working.
The url in both .crates.toml and .crates2.json both require a prefix. Typically this is "registry", however when using a sparse registry it should be "sparse". Some of the code expects this and reading the files now fails.
Install works fine against sparse registries - it is the act of uninstalling is what breaks the files. Other cargo commands seem fine against a sparse repo as well.
Steps
cargo install yaml2json
cargo install grex
From:
grex 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = ["grex"]
To:
grex 1.4.1 (sparse+https://github.com/rust-lang/crates.io-index)" = ["grex"]
cargo uninstall yaml2json
Output:
grex 1.4.1 (https://github.com/rust-lang/crates.io-index)" = ["grex"]
This reproduces without having the actually have a sparse registry. If you have a sparse registry you can skip step 3 as that's just a hack to mimic.
Possible Solution(s)
src/cargo/core/source/source_id.rs - line 724 writes the url as "{url}", however I think it should be writing as "sparse+{url}" based on what the rest of the function is doing.
A workaround for anyone hitting the same problem is to add the "sparse+" back into the crates file (need to do both).
Notes
I've made the change in a test environment and it seems to do the trick, however I don't know what other knock on effects this change may have.
Version
The text was updated successfully, but these errors were encountered: