crates icon indicating copy to clipboard operation
crates copied to clipboard

Support multiple registries (#213)

Open woutersl opened this issue 2 years ago • 4 comments

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.

woutersl avatar Nov 16 '23 14:11 woutersl

Thanks for the effort I will test and publish it if everything goes well

serayuzgur avatar Nov 27 '23 15:11 serayuzgur

@BarbossHack do you have any time to test these, can you help ?

serayuzgur avatar Dec 05 '23 18:12 serayuzgur

@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.

fawadasaurus avatar Feb 02 '24 16:02 fawadasaurus

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) :

"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 have registry = "xxx"
  • check for dependencies that have registry = "my-registry" and use the matching alternate registry my-registry

What do you think ?

BarbossHack avatar Mar 03 '24 13:03 BarbossHack