LukeMathWalker / LukeMathWalker/cargo-chef

How to cache cargo-vcpkg dependencies?

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

Nobody has claimed this yet.

waiting-on-author
Dominant language
Rust
Stars
2.7k
Forks
146
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use cargo-chef for a project that is using [cargo-vcpkg](https://github.com/mcgoo/cargo-vcpkg) for building C++ dependencies.

Is this use case possible with cargo-chef? The following doesn't seem to have the caching effect I'd like since it rebuilds the C++ dependencies every time I make a change.

```
FROM chef AS ffi
COPY . .
RUN cargo vcpkg --verbose build --manifest-path subcrate/Cargo.toml

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

FROM chef AS builder
COPY --from=planner /build/recipe.json recipe.json
COPY --from=ffi /build/target target

RUN cargo chef cook --recipe-path recipe.json

COPY . .
RUN cargo build --bin subcrate
```

The vcpkg build seems to require copying in the workspace Cargo.toml and the subcrate Cargo.toml and code as well, which is why I'm using 'COPY . .' in the ffi layer

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 by reproducing the shown Docker stages with cargo-vcpkg and cargo-chef using the workspace Cargo.toml, subcrate/Cargo.toml, recipe.json, and target directory. Compare which COPY inputs invalidate the ffi layer when source files change. Done means the documented approach preserves the C++ dependency cache across ordinary Rust source changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, rust
Domain
build-system, devops
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.