Skip to content
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

Tracking Issue for serving an index over HTTP #9069

Closed
4 of 11 tasks
ehuss opened this issue Jan 12, 2021 · 21 comments
Closed
4 of 11 tasks

Tracking Issue for serving an index over HTTP #9069

ehuss opened this issue Jan 12, 2021 · 21 comments
Labels
A-sparse-registry Area: http sparse registries C-tracking-issue Category: A tracking issue for something unstable.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 12, 2021

Summary

RFC: #2789
Implementation: #10470
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#sparse-registry
Issues: A-sparse-registry Area: http sparse registries

This is a tracking issue for RFC #2789, an experimental extension to serve the index over HTTP instead of via git.

Unresolved issues

Current best way to test

To try it out, add the -Z sparse-registry flag on nightly-2022-06-20 or newer build
of Cargo. For example, to update dependencies:

rustup update nightly
cargo +nightly -Z sparse-registry update

The feature can also be enabled by setting the environment variable
CARGO_UNSTABLE_SPARSE_REGISTRY=true. Setting this variable will have no effect on stable
Cargo, making it easy to opt-in for CI jobs.

If you see any issues please report them in new tickets here in the Cargo repo. The output of Cargo
with the environment variable CARGO_LOG=cargo::sources::registry::http_remote=trace set
will be helpful in debugging.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Implementation history

@ehuss ehuss added the C-tracking-issue Category: A tracking issue for something unstable. label Jan 12, 2021
@ehuss ehuss changed the title Tracking Issue for servering an index over HTTP Tracking Issue for serving an index over HTTP Feb 13, 2022
bors added a commit that referenced this issue Jun 17, 2022
Use specific terminology for sparse HTTP-based registry

Before the options is popularized, I'd like to take opportunity to give it a unique name used consistently. It's been called "http" registry, but that's a rather generic term, especially that existing git-based registry also uses HTTP as its transport.

New registry URLs use `sparse+https://` prefix, so calling it "sparse" registry seems more appropriate.

#9069
@mightyiam
Copy link

Hey, would this mean that when cargo publish exits with 0 the published crate version is actually available (which is not the case now, due to CDN)?

@kornelski
Copy link
Contributor

It doesn't address this problem. There is still going to be a delay between cargo publish and the crate being available globally. It would be nice to improve this, but it's more of an issue for server-side crates-io implementation than the registry protocol.

@epage
Copy link
Contributor

epage commented Jun 22, 2022

@mightyiam #9507 is the issue you want to be following.

For background, publishing a crate used to be a blocking operation but to speed up crates.io, they made cargo publish just put the crate into a queue for later publishing, making the operation asynchronous.

Tools like cargo-release poll the server. We could easily do similar in cargo until an improved registry protocol is made. I was looking at implementing it but there was a large hurdle for writing the relevant tests. The new sparse registry code has improved the test infrastructure so I could now write the relevant tests.

@tigregalis
Copy link

Can the unstable feature be enabled via .cargo/config.toml?

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 24, 2022

Yes, I think it is:

[unstable]
sparse-registry = true

@ehuss
Copy link
Contributor Author

ehuss commented Aug 31, 2022

Just an update for anyone following this issue. A proposal for how to configure git vs http is available at https://hackmd.io/@rust-cargo-team/B13O52Zko. Additionally #10964 and #10965 contain some more background.

@luciusmagn
Copy link

Hi, has there been any progress on this? Anything I can help with? We would really like to help this get into stable ASAP

@weihanglo
Copy link
Member

weihanglo commented Sep 26, 2022

Thank you for being interested in this feature! The Cargo team and contributors are currently working hard on this topic, as well as collaborating with crates.io team to build up the infrastructure needed (rust-lang/crates.io#5200, rust-lang/crates.io#5112, rust-lang/crates.io#5066, etc).

One of the things we're happy to collect is feedback for this feature. Personally I'd appreciate any user feedback, especially about user experiences. You can find more relevant issues from label https://github.com/rust-lang/cargo/labels/Z-sparse-registry, or in the description of this issue, which contains the development history and unresolved issues.

@jasal82
Copy link

jasal82 commented Dec 1, 2022

@kornelski We're already using that option in the clients. However, for production use we must not use the upstream repositories but Artifactory remote caches instead. Now the problem is that Artifactory cannot properly update its remote caches from the upstream repo when a new previously uncached package is requested. This is definitely a bug in Artifactory but they refuse to fix it and the only answer we got from them is that we should use sparse registries instead which seems to work.

@ahicks92
Copy link

ahicks92 commented Dec 1, 2022

I'd also be interested on when this might hit stable. We also have CI difficulties/runarounds in docker because Cargo deciding that it needs to clone the index from scratch takes a long time for whatever reason, and I suspect we're not alone in that.

For the curious our docker solution is cargo install lazy-static which forces cargo to get an index before failing out because there's no binary target.

@lnicola
Copy link
Member

lnicola commented Dec 2, 2022

For what it's worth, rust-analyzer also tends to get blamed for this ("but after I closed Code, I ran cargo clean and cargo check and they were fast, it's RA that's slow!") because it calls cargo metadata when loading the project.

@ahicks92
Copy link

ahicks92 commented Dec 2, 2022

It's bad even on my gigabit internet at this point if I'm being honest. But since that's once per install that doesn't seem worth complaining about, or something like that. I'll be honest though: I dread that progress bar nowadays.

@ehuss
Copy link
Contributor Author

ehuss commented Jan 4, 2023

A proposal to stabilize this has been posted at #11224.

bors added a commit that referenced this issue Jan 20, 2023
Stabilize sparse-registry

### What does this PR try to resolve?
Stabilize `sparse-registry`
* Does not change the default protocol for accessing crates.io

### How should we test and review this PR?
Set environment variable `REGISTRIES_CRATES_IO_PROTOCOL=sparse` or set in `config.toml`:
```
[registries.crates-io]
protocol = 'sparse'
```

cc #9069
@ehuss
Copy link
Contributor Author

ehuss commented Jan 30, 2023

Sparse registries are now stabilized and will be available in Rust 1.68, which will be released on 2023-03-09. I'm going to close this tracking issue as I think it has served its purpose. There is still some future work to be continued, such as better support for third-party registries. Those issues can be tracked in the A-sparse-registry Area: http sparse registries label.

@Christoph-AK
Copy link

I'm super glad this got merged, but I am having trouble finding the necessary config steps to enable the new behaviour.
Most of the documentation, like in the first post in this issue, still mention it as unstable feature to be enabled with -Z.
Adding [registries.crates-io] protocol = sparse to my cargo.toml doesn't work, i suppose it needs to be added to some cargo config file somewhere else.
Could someone that got it running write some annotations or documentation in some easy to find places?

@JockeTF
Copy link

JockeTF commented Mar 22, 2023

Cargo.toml doesn't work

Agreed, this is a great feature! According to the release notes you're supposed to add the setting to .cargo/config.toml, not Cargo.toml. Either that, or set the environment variable CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse. The release notes have some links to more information as well!

silverwind pushed a commit to go-gitea/gitea that referenced this issue May 3, 2023
This implements the HTTP index
[RFC](https://rust-lang.github.io/rfcs/2789-sparse-index.html) for Cargo
registries.

Currently this is a preview feature and you need to use the nightly of
`cargo`:

`cargo +nightly -Z sparse-registry update`

See rust-lang/cargo#9069 for more information.

---------

Co-authored-by: Giteabot <[email protected]>
@jose-mut-lopez
Copy link

you're supposed to add the setting to .cargo/config.toml, not Cargo.toml.

thanks for this and those links, but for future outsider readers like me, it looks like this became the default in cargo 1.70 which was released on June 2023 (https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#sparse-by-default-for-cratesio), so a better approach now IMO is just to rustup update, which will use the fast index on all repos by default without any per-repo config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sparse-registry Area: http sparse registries C-tracking-issue Category: A tracking issue for something unstable.
Projects
Status: Done
Development

No branches or pull requests