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

Failure to load manifests for workspace members matched by glob

Open seanpianka opened this issue 3 years ago • 1 comments

I have a workspace that defines its members using a glob:

cargo-features = ["resolver"]

[workspace]
members = ["crates/*"]

# ...

When running cook after prepare, I see the following error output which complains that it cannot match any workspace member named *, rather than globbing for all members within the code-specific directory crates/ of my project located at /opt/api/:

#19 [build 11/17] RUN cargo chef cook --recipe-path recipe.json
#19 sha256:c22e9955ddbcc98df6ecc1b985b2bfbbc0ab1d6e32028737a128bdca9569d249
#19 0.767 error: failed to load manifest for workspace member `/opt/api/crates/*`
#19 0.767
#19 0.767 Caused by:
#19 0.767   failed to read `/opt/api/crates/*/Cargo.toml`
#19 0.767
#19 0.767 Caused by:
#19 0.767   No such file or directory (os error 2)
#19 0.773 thread 'main' panicked at 'Exited with status code: 101', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cargo-chef-0.1.41/src/recipe.rs:161:27
#19 0.773 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#19 ERROR: executor failed running [/bin/sh -c cargo chef cook --recipe-path recipe.json]: exit code: 101

Am I using this wrong, or is there still more work to be done on supporting workspaces?

seanpianka avatar Sep 06 '22 22:09 seanpianka

That's correct, we do not supporting globbing syntax at the moment.

A PR would be welcome!

LukeMathWalker avatar Sep 07 '22 08:09 LukeMathWalker

A fix has been released in 0.1.56 thanks to @Kobzol's work 🎉 Can you confirm it works as expected @seanpianka?

LukeMathWalker avatar Apr 17 '23 08:04 LukeMathWalker

I encounter the same error:

 > [builder 2/4] RUN cargo chef cook --release --recipe-path recipe.json:
#0 0.498 error: failed to load manifest for workspace member `/app/./crate/*`
#0 0.498 
#0 0.498 Caused by:
#0 0.498   failed to read `/app/crate/*/Cargo.toml`
#0 0.498 
#0 0.498 Caused by:
#0 0.498   No such file or directory (os error 2)
#0 0.499 thread 'main' panicked at 'Exited with status code: 101', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.61/src/recipe.rs:189:27
#0 0.499 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

version : 0.1.61

nebnes avatar Jun 21 '23 18:06 nebnes

Can you share a reproduction?

LukeMathWalker avatar Jun 22 '23 06:06 LukeMathWalker

Here a repoduction :

Dockerfile :

#---- CREATE SOURCE ----------------------------
FROM rust:1.70-slim-bullseye as source

WORKDIR /src-app
RUN cargo new main_app --bin

COPY <<EOF ./main_app/Cargo.toml
[package]
name = "main_app"
version = "0.1.0"
edition = "2021"
[dependencies]
lib_1 = { path = "../crate/lib_1" }
lib_2 = { path = "../crate/lib_2" }
EOF

RUN mkdir ./crate
RUN cd ./crate && cargo new lib_1 --lib && cargo new lib_2 --lib

COPY <<EOF Cargo.toml
[workspace]
members = [
    "./crate/*",
    "./main_app",
]
EOF


FROM lukemathwalker/cargo-chef:latest-rust-slim-bullseye AS chef
WORKDIR /app


FROM chef AS planner
COPY --from=source /src-app .
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 cat recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY --from=source /src-app .
RUN cargo build --release --bin main_app

# We do not need the Rust toolchain to run the binary!
FROM debian:bullseye-slim AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/main_app /usr/local/bin


ENTRYPOINT ["/usr/local/bin/main_app"]

This works ^^ I find my error in my real project I need to copy local dependencies before cook

nebnes avatar Jun 22 '23 08:06 nebnes