Hi!
FROM rust AS planner
WORKDIR app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
#####################################################
#################### BUILD LAYER ####################
#####################################################
FROM rust as builder
WORKDIR /build
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
COPY . /build
RUN cargo test --lib --release
RUN cargo build --release --bin mypackage
Caused by:
cannot infer path for `mypackage` bin
Cargo doesn't know which to use because multiple target files found at `src/main.rs` and `src/bin/mypackage.rs`.
The command '/bin/sh -c cargo test --lib --release' returned a non-zero code: 101```
Cargo.toml
[[bin]]
name = "mypackage"
[[bin]]
name = "stub"
path = "src/stub.rs"
required-features = ["local"]
Not sure what I am doing wrong in here. The setup worked fine before using cargo chef.
Thanks
Where is the entrypoint for mypackage
? src/main.rs
or src/bin/mypackage.rs
?
Having the same issue and the entry point is src/main.rs
in my version src/bin/mypackage.rs
doesn't exist in the source code and appears to purely be a skeleton artifact from the chef process.
Having the same issue and the entry point is
src/main.rs
in my versionsrc/bin/mypackage.rs
doesn't exist in the source code and appears to purely be a skeleton artifact from the chef process.
My setup is the same.
What is the name of your package and what is the name of your binary (for which you are having issues)? Do they match?
What is the name of your package and what is the name of your binary (for which you are having issues)? Do they match?
Yes they do match (mypackage
). Exact the same test command used to work fine prior using cargo chef
.