LukeMathWalker / cargo-chef

A cargo-subcommand to speed up Rust Docker builds using Docker layer caching.
Apache License 2.0
1.72k stars 113 forks source link

Cargo chief can't fetch packages. #275

Open ultard opened 1 month ago

ultard commented 1 month ago
=> ERROR [bot builder 2/4] RUN cargo chef cook --release --recipe-path recipe.json                                                                    80.9s 
------
 > [bot builder 2/4] RUN cargo chef cook --release --recipe-path recipe.json:
0.737     Updating crates.io index
80.91 error: failed to select a version for the requirement `chrono = "^0.4.38"`
80.91 candidate versions found which didn't match: 0.4.31, 0.4.30, 0.4.29, ...
80.91 location searched: crates.io index
80.91 required by package `bot v0.0.1 (/app/bot)`
80.91 thread 'main' panicked at 'Exited with status code: 101', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cargo-chef-0.1.35/src/recipe.rs:145:27
80.91 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------
failed to solve: process "/bin/sh -c cargo chef cook --release --recipe-path recipe.json" did not complete successfully: exit code: 101
`docker-compose` process finished with exit code 17
[package]
name = "bot"
version = "0.1.1"
edition = "2021"

[dependencies]
dotenvy = '0.15.7'
tracing = "0.1"
tracing-subscriber = "0.3"
serde_json = "1"
futures = "0.3"
humantime = "2.1.0"
anyhow = "1.0.86"
extend = "1.2"
chrono = "0.4.38"
thiserror = "1.0.62"

[dependencies.poise]
version = "0.6"
default-features = false
features = ["cache", "chrono", "handle_panics"]

[dependencies.songbird]
version = "0.4.3"
default-features = false
features = ["gateway", "serenity", "native"]

[dependencies.tokio]
version = "1"
features = ["rt-multi-thread", "macros"]

[dependencies.lavalink-rs]
path = "../lavalink-rs"
default-features = false
features = ["songbird", "serenity", "native-tls", "macros"]
FROM lukemathwalker/cargo-chef:latest-rust-1.59.0 AS chef
WORKDIR app

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --bin bot

# We do not need the Rust toolchain to run the binary!
FROM alpine:latest AS bot
WORKDIR app
COPY --from=builder /app/target/release/bot /usr/local/bin
ENTRYPOINT ["/usr/local/bin/bot"]

When i try to build dockerfile i get an error what chrono version is not found, but this package version is exsists

https://crates.io/crates/chrono image

xbtmatt commented 2 weeks ago

I get error code 101 as well, but I get this:

55.95 error: RPC failed; curl 92 HTTP/2 stream 5 was not closed cleanly: CANCEL (err 8)
55.95 error: 19 bytes of body are still expected
55.95 fetch-pack: unexpected disconnect while reading sideband packet
55.95 fatal: early EOF
55.95 fatal: fetch-pack: invalid index-pack output
55.95 error: failed to get `aptos-system-utils` as a dependency of package `server-framework v0.0.1 (/app/server-framework)`

I think it's because of memory limits in Docker, since the repo I'm pulling from (aptos-core) is quite large.