Daniel W
Daniel W

Reputation: 144

How can I fix "unable to update registry, network failure seems to have happened" error when building with cargo in Docker container?

I'm trying to build a program with cargo in a Docker container but it fails:

# Compile KissMP
FROM --platform=arm64 ubuntu:20.04

# Install dependencies
RUN apt-get update
RUN apt-get install -y cargo
RUN apt-get install -y git

# Clone & Build KissMP
WORKDIR /build
RUN git clone -b lib https://github.com/vulcan-dev/KISS-multiplayer.git
WORKDIR /KISS-multiplayer
WORKDIR /build/KISS-multiplayer/kissmp-server/
RUN cargo build --release
#24 2.299     Updating crates.io index
#24 681.7 error: failed to get `anyhow` as a dependency of package `kissmp-bridge v0.5.0 (/build/KISS-multiplayer/kissmp-bridge)`
#24 681.7 
#24 681.7 Caused by:
#24 681.7   failed to load source for dependency `anyhow`
#24 681.7 
#24 681.7 Caused by:
#24 681.7   Unable to update registry `crates-io`
#24 681.7 
#24 681.7 Caused by:
#24 681.7   failed to fetch `https://github.com/rust-lang/crates.io-index`
#24 681.7 
#24 681.7 Caused by:
#24 681.7   network failure seems to have happened
#24 681.7   if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
#24 681.7   https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
#24 681.7 
#24 681.7 Caused by:
#24 681.7   SSL error: unknown error; class=Ssl (16)

Does anyone know a fix for this?

Note: I cannot use Alpine

Upvotes: 4

Views: 4388

Answers (2)

basically ahash version in cargo.toml was either 0.7..7 or 0.8.7, but the build seems to fail with it

cargo update -p ahash:0.8.7 --precise 0.8.6 to update the cargo tree

Upvotes: -1

Daniel W
Daniel W

Reputation: 144

I added CARGO_NET_GIT_FETCH_WITH_CLI=true before cargo build and now it works.

Upvotes: 4

Related Questions