-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Git resolver looses custom registry url #15502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can understand that it can be frustrating to have to propagate out the definition of custom registries to all relevant repo. However, config files are loaded based on your current environment (with an exception for See also
I'm not quite seeing this as a man-in-the-middle as the config has to be on your local system which puts it in your control. Relying on configs in remote repos which you have no control over and not easy visibility for auditing seems like it would make this problem worse. |
I don't think it is sound fetch the registry by "name" rather than URL. A name is by definition local and should only concern my local crate, it should not be the burden of the consumer of my library to know whatever registry name me or my downstream dependencies are using. Imagine if we have 20 dependencies each of them defining their own registry name, as a top-level binary I would have to put each of them in my config.toml despite they all have the same URL (= poiting to the same registry in reality). This does not sound optimal at all. |
In that case, the most likely path forward would be to evaluate having the URL in |
Also, do you know why it only happens when using a git dependency ? If a dependency is directly fetched from a registry there is no issue and it is not needed to have all the registries named correctly in config.toml. I am not familiar at all with the cargo code base, but is there a world where cargo could always fetch by URL? Just keeping the name for convenience intra-crate? |
Cargo has an internal-only field it sets when generating a |
@epage do you think that this could be tackled by a newcomer in the codebase? I would be happy to do it provided the right guidance. |
The first step is finding out why things work this way, in particular, what is split with the name in manifests and url in config. I wasn't around for that decision so someone will need to dig into the issues, prs, or maybe source history to uncover that. |
Problem
When depending on custom registries over Git, the URL to the registry is lost, forcing the user to redefine it in its own .cargo/config.toml.
This put the responsibility on the consumer to know about the custom registries of its Git dependencies.
This also allow some "man on the middle" trick by providing another second level dependency by defining same registry name with different URL in the consumer .cargo/config.toml.
Steps
Possible Solution(s)
One possible solution will be to resolve dependency url using the .cargo/config.toml at the level the dependency is defined.
Notes
If crate-b -> crate-a -> some-crate only involves Git resolver or custom registry there is no issue.
Only happens when Git and Custom registry are mixed.
Version
The text was updated successfully, but these errors were encountered: