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

error: failed to get 'actix-rt' as a dependency of package #10221

Closed
sm8082 opened this issue Dec 20, 2021 · 4 comments
Closed

error: failed to get 'actix-rt' as a dependency of package #10221

sm8082 opened this issue Dec 20, 2021 · 4 comments

Comments

@sm8082
Copy link

sm8082 commented Dec 20, 2021

Hello, I'm getting error whilst building a new image using Dockerfile for a Rust program.

Code in my "main.rs" as below:
use actix_web::{web, App, HttpResponse, HttpServer, Result};
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(||{
App::new()
.service(web::resource("/").route(web::get().to(index)))
})
.bind("0.0.0.0:4400")?
.run()
.await
}
async fn index() -> Result {
println!("Ch13 Docker Test");
Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(include_str!("../static/index.html")))
}

Cargo.toml dependencies:
[dependencies]
actix-web = "2.0.0"
actix-rt = "1.0.0"

Dockerfile code:
FROM rust:1-slim-buster AS base
ENV USER = root
WORKDIR /code
#RUN cargo init
COPY Cargo.toml /code/Cargo.toml
#RUN cargo fetch
COPY src/ src/
CMD ["cargo", "test", "--offline"]
FROM base AS builder
RUN cargo build --release
FROM rust:1-slim-buster
COPY --from=builder /code/target/release/Ch13_docker_test /usr/bin/Ch13_docker_test
EXPOSE 4400
ENTRYPOINT ["/usr/bin/Ch13_docker_test"]


When I run "sudo docker build -t ch13_docker1g .", I get the following error on my terminal in Linux:

Step 8/12 : RUN cargo build --release
---> Running in 6b81f85ebb2b
Updating crates.io index
error: failed to get actix-rt as a dependency of package Ch13_docker_test v0.1.0 (/code)

Caused by:
failed to load source for dependency actix-rt

Caused by:
Unable to update registry crates-io

Caused by:
failed to fetch https://github.com/rust-lang/crates.io-index

Caused by:
network failure seems to have happened
if a proxy or similar is necessary net.git-fetch-with-cli may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
SSL error: received early EOF; class=Ssl (16); code=Eof (-20)
The command '/bin/sh -c cargo build --release' returned a non-zero code: 101


It is causing too much pain and delays, if it could be resolved please. As per above it says network failure but this is not true because the net is clearly working fine.

@ehuss
Copy link
Contributor

ehuss commented Dec 20, 2021

Hm, I'm unfortunately unable to reproduce with that docker image.
Are you behind a proxy or have any other unusual network setup?
Does it continue if you set the net.git-fetch-with-cli config option to true?

@sm8082 sm8082 closed this as completed Dec 20, 2021
@sm8082
Copy link
Author

sm8082 commented Dec 20, 2021

Thanks for looking into this ehuss. I got it resolve by running the following commands, so it seems that my cargo required these updates:

cargo install cargo-vendor
cargo vendor
cargo install cargo-bdeps

@CodingProgrammer
Copy link

I got wrong after run "cargo vendor"

Caused by:
  failed to load pkg lockfile

Caused by:
  failed to select a version for the requirement `rhai = "^1.8"`
  candidate versions found which didn't match: 1.7.0, 1.6.1, 1.6.0, ...
  location searched: crates.io index
  required by package `cargo-generate v0.16.0`
      ... which satisfies dependency `cargo-generate = "^0.16.0"` of package `webservice v0.1.0

anyone can help me ?

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 10, 2022

@Smilejohnson, what version of cargo are you using. This may be a case off #10623

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants