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

0

Where is the entrypoint for mypackage? src/main.rs or src/bin/mypackage.rs?

0

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.

0

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.

My setup is the same.

0

What is the name of your package and what is the name of your binary (for which you are having issues)? Do they match?

0

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.

0

It should be fixed in 0.1.38!

2

Can confirm it works!

0
© 2022 pullanswer.com - All rights reserved.