LukeMathWalker/cargo-chef

`split-debuginfo = "unpacked"` is not part of recipe

Closed this issue · 1 comments

Problem

Our crates use unpacked debuginfo which are not copied to recipe.json which makes cargo build rebuild everything, making the cache step useless.

Reproduction

Setup a project:

cargo new --lib dummy
cd dummy
cargo add tokio --features full
cat << EOF >> Cargo.toml
[profile.dev]
split-debuginfo = "unpacked"
EOF

Create a Dockerfile

FROM rust:slim-bullseye AS chef
RUN cargo install cargo-chef

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

FROM chef AS builder
COPY --from=planner /recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json
COPY . .
# Rebuilds everything from scratch
RUN cargo build

Build it: docker build -t foo .

Workaround

I didn't find a suitable workaround. It would be needed to fix the generated Cargo.toml before the project is built during cargo chef cook. It might be possibl to manually fix the recipe.json file.

Context

This may also happen with other options. This is also an issue for workspace-level Cargo.toml.

split-debuginfo needs to be added to the Profile struct in cargo-manifest. Then everything should work as expected.

Feel free to submit a PR!