This patch deletes the workspace.default-members array in the skeleton derived from Cargo.toml if it exists.
Cargo errors out if workspace.default-members contains entries that don't exist in workspace.members. But cargo chef prepare --bin modifies workspace.members as part of its normal operation, leaving the other fields untouched.
default-members is an entirely end-user-facing setting that controls which workspace members are built when running cargo {check, build, test} (among others) at the workspace root without specifying a target package. It has no effect on cargo chef cook.
Cook it (this overrides the contents of the directory because we are outside of docker, but that's ok because we are just demonstrating the behaviour; the error is the same as would be seen in docker):
$ cargo chef cook --bin foo --recipe-path recipe.json
error: package `/Users/janis/dev/scratch/demo-cargo-chef-default-members/bar` is listed in workspace’s default-members but is not a member.
thread 'main' panicked at 'Exited with status code: 101', /Users/janis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-chef-0.1.61/src/recipe.rs:189:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The Cargo.toml overridden by the cook showing the problem (default-members contains entries not in members):
This patch deletes the
workspace.default-members
array in the skeleton derived fromCargo.toml
if it exists.Cargo errors out if
workspace.default-members
contains entries that don't exist inworkspace.members
. Butcargo chef prepare --bin
modifiesworkspace.members
as part of its normal operation, leaving the other fields untouched.default-members
is an entirely end-user-facing setting that controls which workspace members are built when runningcargo {check, build, test}
(among others) at the workspace root without specifying a target package. It has no effect oncargo chef cook
.The before/after behavior is described below.
Buggy behaviour this patch fixes
Create the following workspace:
Prepare a recipe for only
foo
:Cook it (this overrides the contents of the directory because we are outside of docker, but that's ok because we are just demonstrating the behaviour; the error is the same as would be seen in docker):
The
Cargo.toml
overridden by the cook showing the problem (default-members
contains entries not inmembers
):After this patch:
Cook and the resulting overriden local
Cargo.toml
: