LukeMathWalker / LukeMathWalker/cargo-chef

Add support for `--example` to `cargo chef cook`

Open
#322 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
2.7k
Forks
146
PR merge metrics
No merged PRs in 30d

Description

I'm building some example code using:
```
FROM chef AS planner

COPY . .
RUN cargo chef prepare --recipe-path recipe.json --bin my-example

FROM chef AS builder

COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY . .
RUN cargo build --release -p my-example --example my-example
```

And sadly it seems the dependencies that are being compiled by the `cook` step are not the same ones as the ones used by `cargo build --example my-example`, and so it's rebuilding it all.

I've found that `cook` supports `--examples`, but it seems sometimes it's not always building all the required dependencies for my example binaries, it allows to not rebuild all the dependencies, however, only a few.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the `cargo chef cook` command and compare its existing `--examples` handling with the reported `cargo build --example my-example` workflow. Trace how the recipe identifies example dependencies; done means a supported `--example` option causes `cook` to compile the dependencies needed by that example without rebuilding them afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.