cargo-chef icon indicating copy to clipboard operation
cargo-chef copied to clipboard

Unable to build `rustls` with `cargo-chef`

Open Walther opened this issue 1 year ago • 0 comments

The title of this issue is very specific, but I think it is likely the underlying cause affects other projects as well.

Given a fresh clone of rustls currently at commit fc6b4a193b065604d10e16e79d601d8a30c18492, and the following Dockerfile

FROM lukemathwalker/cargo-chef:latest-rust-1.82 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
RUN cargo chef cook --release --recipe-path recipe.json --package rustls

COPY . .
RUN cargo build --release --package rustls
ENTRYPOINT []

Running docker build --tag rustls-chef --progress=plain --no-cache . results in the following error at the cook stage:

#10 0.452     Updating crates.io index
#10 0.463 error: failed to get `rustls-post-quantum` as a dependency of package `bogo v0.0.1 (/app/bogo)`
#10 0.463
#10 0.463 Caused by:
#10 0.463   failed to load source for dependency `rustls-post-quantum`
#10 0.463
#10 0.463 Caused by:
#10 0.463   Unable to update /app/rustls-post-quantum
#10 0.463
#10 0.463 Caused by:
#10 0.463   failed to read `/app/rustls-post-quantum/Cargo.toml`
#10 0.463
#10 0.463 Caused by:
#10 0.463   No such file or directory (os error 2)
#10 0.464 thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.68/src/recipe.rs:218:27:
#10 0.464 Exited with status code: 101
#10 0.464 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#10 ERROR: process "/bin/sh -c cargo chef cook --release --recipe-path recipe.json --package rustls" did not complete successfully: exit code: 101
------
 > [builder 2/4] RUN cargo chef cook --release --recipe-path recipe.json --package rustls:
0.463   Unable to update /app/rustls-post-quantum
0.463
0.463 Caused by:
0.463   failed to read `/app/rustls-post-quantum/Cargo.toml`
0.463
0.463 Caused by:
0.463   No such file or directory (os error 2)
0.464 thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.68/src/recipe.rs:218:27:
0.464 Exited with status code: 101
0.464 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Speculation: perhaps cargo-chef is not taking into account the workspace excludes correctly? The mentioned package rustls-post-quantum is not supposed to be included by default

## Deliberately not included in `members`:
exclude = [
  # `cargo fuzz` integration (requires nightly)
  "fuzz",
  # experimental post-quantum algorithm support
  # (conflicting feature requirements with `rustls`)
  "rustls-post-quantum",
]

Walther avatar Nov 26 '24 10:11 Walther