Closed DCjanus closed 4 years ago
This... doesn't look right. Take for example the test you edited: it no longer fully resolves down to tralternative, stopping at the registry it originally resolved the URL/name for; why? What final cargo install
invocation are you seeing versus what are you expecting to see?
Example config file:
[source.crates-io]
replace-with = "sjtu"
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
In this case, origin code, cargo-update
would try to cargo install --registry sjtu --version x.y.z my_package
, with message Updating registry "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
, which would be failed. Because there is no sjtu
registry, it's just a proxy for crates-io
.
With this PR, that would be cargo install --registry crates-io --version x.y.z my_package
and show me this Updating registry "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
, and works fine in my case.
In fact, registry
in cargo install
, it means to install package from crates-io
or your private registry. And replace-with
would not replace registry identity but registry
field, which is for public registry proxy.
If you are trying to reproduce it, try this:
cargo install --version 3.0.0 cargo-update
cargo install-update cargo-update
Thanks for the details, they've allowed me to verify the implementation and this seems like a cargo regression from nightly-2019-08-10-x86_64-unknown-linux-gnu
, with nightly-2019-09-10-x86_64-unknown-linux-gnu
being the first regressed version I found that exhibits this
I'm going to open an issue on the cargo repository and drink now
I also came across (well, "came across", I wrote multiple comments and a 6-commit implementation, maybe I'm just old) https://github.com/nabijaczleweli/cargo-update/issues/128#issuecomment-597887413, which was illuminatory:
cargo install --registry NAME
requires registries.NAME.index
instead of source.NAME.registry
(the documentation was updated on 3 Dec 2019 in https://github.com/rust-lang/cargo/commit/dd8f7d8d8f65b3b0f29b53153b6204b636a110bf, but nightly-2019-08-10
works, nightly-2019-09-10
already doesn't),source.NAME.{registry,replace-with}
and specify the registry we resolved to, soregistries.NAME.index
and source.NAME.registry
values need to match.I saw cargo install --index URL
in the cargo source which'd let us avoid the naming and just use the URLs we deal in anyway but it's only 2 months old, so no dice.
I'll write some documentation when I'm less angry and more sober. Thanks again for your testcases, and, mayhap more importantly, persistence.
Can you try adding this to your config:
[registries.sjtu]
index = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
and running an update operation again?
That's what I documented to work in cef1717460a6079f491798b1787e7f887ce06dbc, and a test result from you would be great.
Sad to say this: this don't work with me.
Here is my config file:
[source.crates-io]
replace-with = "sjtu"
[registries.sjtu]
index = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
I've tried cargo install-update --all
, and got this:
Couldn't get registry for cargo-edit: Couldn't find appropriate source URL for https://github.com/rust-lang/crates.io-index in C:\Users\DCjanus\.cargo\config (resolved to "sjtu").
Oh, what a mistake I've made!
I've took a wrong title, it should be source replacement
rather than alternate registry
.
Your entire config unfortunately needs to be:
[source.crates-io]
replace-with = "sjtu"
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
[registries.sjtu]
index = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
Can you try that instead?
Can you try that instead?
I met the same problem with @DCjanus, and when I try this config, after running cargo install-update -a
, I got
Couldn't get package repository: Couldn't read /home/vitalyr/.cargo/registry/index/mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b (index directory for https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index): No such file or directory (os error 2).
So this config doesn't solve the problem.
Actually there are many guides for replacing the official crates.io-index with sjtu's mirror in Chinese Internet, which guide people to set the same .cargo/config with @DCjanus 's. It' s not a good choice to force users to edit their config to use cargo-update
.
cargo-update
is really awesome, why not improve it by accepting this pr?
Because, well, it doesn't actually solve the underlying problem (that being: cargo's stability guarantees are bullshit) (and also it's kinda subtly wrong in what it produces, but that's beside the point).
It works entirely by accident because sources.crates-io
is the default and so is registries.crates-io
.
What's the output of find .cargo/registry/ -maxdepth 2 -type d
for you, @VitalyAnkh? Does running cargo install --registry sjtu lazy_static
(ignore the error), then running cargo install-update -a
again fix the problem?
Documentation released in v4.1.0
, but I'm open to further troubleshooting if your MIA isn't permanent.
fix: #137