-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
@rfcbot fcp merge
This issue is to track the proposal to stabilize alternative registries.
RFC: 2141
Tracking Issue: rust-lang/rust#44931
Stabilization Target: 1.34 — Release date Apr 11 2019
What is being stabilized
Alternate registries allows Cargo to use registries other than crates.io. The following is an overview of the surface changes:
-
Alternate registries are defined in
.cargo/configunder theregistriestable, example:[registries] my-registry = { index = "https://my-intranet:8080/git/index" }
-
Dependencies in
Cargo.tomlcan reference other registries with theregistrykey, example:[dependencies] other-crate = { version = "1.0", registry = "my-registry"}
-
Commands may take the
--registryflag to specify the server to interact with. This includesinstall,login,owner,publish,search, andyank.newandinitalso take the same flag to initialize thepublishfield. Example:cargo publish --registry my-registry
- The default for
--registrymay be specified in.cargo/configwith theregistry.defaultkey (exceptnewandinit, see cargo publish should be opt-in #6153). Example:
[registry] default = "my-registry"
- The default for
-
Manifests may restrict which registry they may interact with the
publishkey, example:[package] publish = ["my-registry"]
-
Authentication information saved by
cargo loginis stored in.cargo/credentialsunder the registries table:[registries.my-registry] token = "854DvwSlUwEHtIo3kWy6x7UCPKHfzCmy"
-
Ancillary feature support:
cargo metadataexposes theregistryfield for dependency declarations.sourceand PackageID fields also point to the registry.[patch]tables can be a registry name or index URL.- Registries may opt-out of Web API support, in which case commands like
publishdisplay an appropriate error message.
-
Misc post-RFC decisions:
- Registries as URLs in
Cargo.tomlare currently not allowed. - Registry names are restricted to the same format as package names (alphanumeric characters, dash, and underscore only).
- Registry URLs in
[registries]may contain usernames, but not passwords. - The crates.io codebase won't currently cater towards being used for alternative registries. Cargo refuses to publish alternative dependencies to crates.io, and crates.io double-checks to prevent it.
generate-index-metadatawill currently not be implemented directly in Cargo. cargo-index is a demonstration of how it can be implemented usingcargo metadata.- cargo-reg is a third-party util to assist adding registries to
.cargo/config.
- Registries as URLs in
-
Documentation: I have written a new chapter for the Cargo Reference that goes into depth about registries. This includes how to use them, how to run one, the index format, and the minimum required Web API. I will be posting this soon.