Support multiple registries (#213)
Hi, This is an attempt to support multiple registries. This change adds a new configuration for the specification of the additional registries, so that it is backward compatible with existing configurations. The implementation is simply to attempt to get the data from all registries and merge them by keeping the first successful response. It is a bit brutal but it works and is a minimal change. I tested this on my end, works like a charm with a private registry in addition to crates.io.
Thanks for the effort I will test and publish it if everything goes well
@BarbossHack do you have any time to test these, can you help ?
@woutersl
How does this work with private registries that require authentication? I have my PAT in my ~/.cargo/permissions.toml file but don't see anything in here that would use that.
imho this MR is far from being able to be merged, unfortunately...
It's not a common "rust behavior" to have multiple "transparent registries" like that. You can only have one "main registry" (usually index.crates.io), and mutiple alternate registries. The main difference here is that all the "alternate registries" must be declared in .cargo/config.toml with a name; and when used in a Cargo.toml it MUST specify the alternate registry name if any :
[dependencies]
other-crate = { version = "1.0", registry = "my-registry" }
Instead, in this MR you check all alternate registries when it does not succeed with the main registry, but you don't care either it should be check only with the main registry or with an alternate registry (and with which one). It could lead to a lot of unwanted behaviors... (checking the version on the wrong registry, etc...)
Also, like @fawadasaurus said, it should support alternate registry authentification.
Here is how it should be implemented (imho) :
- use the following vscode config (or directly read the .cargo/config.toml) :
"crates.alternateRegistries": [
{
"name": "my-registry",
"index": "https://my-intranet:8080/git/index",
"token": "854DvwSlUwEHtIo3kWy6x7UCPKHfzCmy"
}
],
- do NOT use the main registry (
indexServerURL) to check version of dependencies that haveregistry = "xxx" - check for dependencies that have
registry = "my-registry"and use the matching alternate registrymy-registry
What do you think ?