-
Notifications
You must be signed in to change notification settings - Fork 89
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
Cargo stuck at "Updating crates.io" #111
Comments
had the same issue.
for some time. And then throws errors
Finally, I was managed to fix it by setting up DSN before run cargo install/build
however, this looks like a temporary workaround and I think it should be better solved in some other way. |
Also, according to this to solve this you can add this in your
|
I have the same problem. |
@SET001 your fixes aren't working. |
I'm on Arch Linux, too. |
Yep, here too, not working. |
Hey, guys, the same problem, it can be reproduce with this docker file: FROM rust:latest
WORKDIR /usr/src/myapp
COPY . .
RUN cargo install --path .
CMD ["myapp"] On a new project [package]
name = "myapp"
version = "0.1.0"
edition = "2021"
[dependencies]
rand_core = "0.6.4" without dependencies all working |
@Luchanso how much time did you give to it? I gave it like 30 minutes and then it worked. |
@roj1512 about 15 minutes, but I'm not ready wait 30 minutes every time when I need new build I'll try later some older versions of base image for building (I'll write here if they work) |
@Luchanso The long wait was only once for me. |
@roj1512 yes, because Docker have cache, but if you add new dependency, cache will invalidate and new build take again 30 min |
Exactly... |
@roj1512 yes, I think so this happening because cargo trying download large index (117 mb) very slow Workaround solution in single commandFROM rust:latest
# install crates.io index and cache it in the docker layer
RUN cargo new --bin build-index \
&& cd build-index \
&& cargo add rand_core \
&& cd .. \
&& rm -rf build-index
# ... other stuff ... Explain:
Why is this a tradeoff? You need sometime reset cache layer, because index will outdate in time Workaround solution 2Or you can use rust nightly build and skip building index, but I don't verified this way and don't know pitfalls And I'll reopen issue rust-lang/cargo#5721, because progress indicator not working in docker build |
Interesting RFC about this problem https://rust-lang.github.io/rfcs/2789-sparse-index.html |
Having the same issue. I am able to add the dependencies using @Luchanso's workaround either in the Dockerfile or via terminal, but it throws the same error during the Also, it builds perfectly fine when I leave out certain dependencies in my Note: I am using MacOs with a 2.3 GHz 8-Core Intel Core i9 processor, and 32 GB 2400 MHz DDR4 memory, and my internet connection is stable & fast (440 Mbps download, 20 Mpbs upload) Since |
@myssynglynx no, internet connection not affected with it, this index (~117 mb) storing on github and github limiting download speed with 32 - 128 kb/sec, so that 117 mb / 32 kb/sec ≈ 60 min for downloading index. Rust team can solve this problem with two ways:
But I think any $6 hosting with unlimited traffic and bandwidth 200 mb/sec handle with this task |
@myssynglynx I found second workaround solution, you can copy cargo cache index from your computer into docker container For MacOS: cd my-project
cp -r ~/.cargo/registry ./registry For Linux: cd my-project
cp -r /usr/local/cargo/registry ./registry Dockerfile: FROM rust:alpine3.17
COPY registry /usr/local/cargo/registry
# .... other stuff .... |
@Luchanso This works. Thank you so much. It would be nice to not have to depend on anything from the developer's machine in order to get this running, but for now this will do. |
Using sparse-registry seems to solve the problem. https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html |
OS: Arch Linux
Kernel: 5.18.16-arch1-1
Docker version: Docker version 20.10.17, build 100c70180f
I have been trying to get docker working for an app I was working on, but when I install packages, cargo gets stuck at "Updating crates.io" I tried some solutions, but none of them proved effective. Here's my Dockerfile:
The text was updated successfully, but these errors were encountered: