Open hoxxep opened 9 months ago
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?
After https://github.com/LukeMathWalker/cargo-chef/pull/260 it is possible to do:
cargo chef cook --no-build
cargo fetch
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:
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:
I can see an outstanding issue (https://github.com/LukeMathWalker/cargo-chef/issues/180) that hints at usage of a workspace with multiple crates and may be suffering the same fate.
Proposal
Add a
cargo chef fetch
orcargo chef cook --download-only
to download dependencies, but avoid compiling them. I'm ignorant to howcargo chef
is implemented, but thecargo 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?