Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --download-only option for multi-crate workspaces #250

Open
hoxxep opened this issue Nov 24, 2023 · 2 comments
Open

Add --download-only option for multi-crate workspaces #250

hoxxep opened this issue Nov 24, 2023 · 2 comments

Comments

@hoxxep
Copy link

hoxxep commented Nov 24, 2023

Context

I had run into an issue where chef wasn't caching properly because I'm using a workspace with multiple crates.

A minimal Dockerfile example could be:

ARG PROFILE=release
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release -p package
# alternative: cargo install --path package

Here, the package chosen may change the feature selection on some dependencies, which can cause a large recompile. Chef will have built for all packages, and so the dependencies will use the maximal feature set, while the build -p package may choose a smaller feature set for some dependencies and recompile a large amount of code.

In my particular case, I have a single cargo workspace and Dockerfile where I am building multiple containers from different crates.

The options for cargo chef in a workspace are either:

  1. chef for all packages, build for all packages
  2. chef per-package, build per-package
    1. alternative: chef fetch for all packages, chef cook per-package, build per-package

I can see an outstanding issue (#180) that hints at usage of a workspace with multiple crates and may be suffering the same fate.

Proposal

Add a cargo chef fetch or cargo chef cook --download-only to download dependencies, but avoid compiling them. I'm ignorant to how cargo chef is implemented, but the cargo fetch command could hopefully provide the functionality?

Documentation

It might be worth adding a point about workspaces and crates depending on different features, it took me a few hours to figure out what was happening! Perhaps as a troubleshooting guide, or some form of "here's what's recommended for workspaces with multiple crates" section in the README?

@mladedav
Copy link
Contributor

mladedav commented Feb 6, 2024

I've had the same issue, try running it with --bin package instead. That should use the same features as the workspace.

Or do you need the package to have different features than the workspace?

@markdingram
Copy link
Contributor

After #260 it is possible to do:

cargo chef cook --no-build
cargo fetch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants