File tree 4 files changed +20
-11
lines changed
4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ impl<'cfg> HttpRegistry<'cfg> {
131
131
config : & ' cfg Config ,
132
132
name : & str ,
133
133
) -> CargoResult < HttpRegistry < ' cfg > > {
134
- if !config. cli_unstable ( ) . sparse_registry {
134
+ if !source_id . is_crates_io ( ) && ! config. cli_unstable ( ) . sparse_registry {
135
135
anyhow:: bail!( "usage of sparse registries requires `-Z sparse-registry`" ) ;
136
136
}
137
137
let url = source_id. url ( ) . as_str ( ) ;
Original file line number Diff line number Diff line change @@ -891,6 +891,13 @@ commands like [`cargo publish`] that require authentication.
891
891
892
892
Can be overridden with the ` --token ` command-line option.
893
893
894
+ ##### ` registries.crates-io.protocol `
895
+ * Type: string
896
+ * Default: ` git ` (or ` sparse ` ` -Z sparse-registry ` is passed)
897
+ * Environment: ` CARGO_REGISTRIES_CRATES_IO_PROTOCOL `
898
+
899
+ Specifies the protocol used to access crates.io. Allowed values are ` git ` or ` sparse ` .
900
+
894
901
#### ` [registry] `
895
902
896
903
The ` [registry] ` table controls the default registry used when one is not
Original file line number Diff line number Diff line change @@ -832,7 +832,7 @@ fn main() {
832
832
* Tracking Issue: [ 9069] ( https://github.com/rust-lang/cargo/issues/9069 )
833
833
* RFC: [ #2789 ] ( https://github.com/rust-lang/rfcs/pull/2789 )
834
834
835
- The ` sparse-registry ` feature allows cargo to interact with remote registries served
835
+ The ` sparse-registry ` feature allows Cargo to interact with remote registries served
836
836
over plain HTTP rather than git. These registries can be identified by urls starting with
837
837
` sparse+http:// ` or ` sparse+https:// ` .
838
838
@@ -841,6 +841,17 @@ crates, which can save significant time and bandwidth.
841
841
842
842
The format of the sparse index is identical to a checkout of a git-based index.
843
843
844
+ Note that this feature is not required for accessing crates.io over the sparse protocol.
845
+ To set the protocol used for crates.io, set in a [ config file] :
846
+ ``` toml
847
+ [registries .crates-io ]
848
+ protocol = ' sparse'
849
+ ```
850
+ Or use the environment variable ` CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse ` .
851
+
852
+ Enabling this feature changes the default protocol for accessing crates.io to from ` git `
853
+ to ` sparse ` .
854
+
844
855
### credential-process
845
856
* Tracking Issue: [ #8933 ] ( https://github.com/rust-lang/cargo/issues/8933 )
846
857
* RFC: [ #2730 ] ( https://github.com/rust-lang/rfcs/pull/2730 )
Original file line number Diff line number Diff line change @@ -2703,15 +2703,6 @@ fn http_requires_z_flag() {
2703
2703
. run ( ) ;
2704
2704
}
2705
2705
2706
- #[ cargo_test]
2707
- fn protocol_sparse_requires_z_flag ( ) {
2708
- cargo_process ( "install bar" )
2709
- . with_status ( 101 )
2710
- . env ( "CARGO_REGISTRIES_CRATES_IO_PROTOCOL" , "sparse" )
2711
- . with_stderr ( "[ERROR] usage of sparse registries requires `-Z sparse-registry`" )
2712
- . run ( )
2713
- }
2714
-
2715
2706
#[ cargo_test]
2716
2707
fn protocol ( ) {
2717
2708
cargo_process ( "install bar" )
You can’t perform that action at this time.
0 commit comments