Config-independent way of specifying alternative registry in Cargo.toml #14500
Labels
A-configuration
Area: cargo config files and env vars
A-interacts-with-crates.io
Area: interaction with registries
A-manifest
Area: Cargo.toml issues
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Command-package
Command-publish
S-needs-team-input
Status: Needs input from team on whether/how to proceed.
Problem
Cargo allows pulling dependencies from alternative registries by specifying
registry = "name"
in deps' details inCargo.toml
.However, the registry name itself is not sufficient to identify the registry to use. It is an arbitrary nickname given in
.cargo/config.toml
(or even its substitute like an env var). The flexibility of this level of indirection is generally very useful during development, but it also means that theCargo.toml
information is not fully self-contained, and its real meaning depends on the environment.This becomes more of an issue when publishing crates to a registry. The Publish API contains a JSON blob that translates the
registry
nicknames into proper absolute URL. But the JSON blob in the Publish API is separate fromCargo.toml
, and to protect against mischievous clients, a registry server should be verifying data directly fromCargo.toml
. Lack of registry URLs in theCargo.toml
is the only reason to keep the otherwise redundant JSON blob.Proposed Solution
Cargo already rewrites
Cargo.toml
when publishing. If the manifestregistry
key was extended to allow full URLs, then Cargo could make the manifest unambiguous and self-contained during publishing.The
registry
field in the JSON blob treatsnull
value as "the registry I'm uploading to". This is very useful for the registries, since recognizing registry's own external name can be tricky (if the server is behind a proxy). This would need a special-case value inCargo.toml
too, different from absence of theregistry
key to avoid ambiguity with crates-io (mayberegistry = "self"
).Another option would be to add a mapping table to
Cargo.toml
, such as[registries] name = "url"
.Notes
No response
The text was updated successfully, but these errors were encountered: