Description
Context
I have a Cargo workspace with multiple members. Inside my workspace, crates should depend on each other. So if my workspace contains both lib_foo
and my_bin
depending on lib_foo
, then my_bin
should always use the version from the repository when working locally (cargo run
, cargo test
, etc.).
I know of two ways to achieve this:
- In
my_bin
, define the dependency aslib_foo = {version = "0.1.0", path = "../lib_foo"}
. - At the workspace level, define
patch.crates-io.lib_foo = {path = "./lib_foo"}
, then insidemy_bin
use a regular dependencylib_foo = "0.1.0"
The second style has the benefit that once a release is published to crates.io
, then my_bin
can be zipped and sent to be executed outside of the workspace without any changes (and without having to include lib_foo
in the archive). This property is pretty useful.
Issue
If I run cargo set-version
in the workspace described above, both crates lib_foo
and my_bin
are updated to 0.2.0
. However, the dependency requirement is only updated when using the first method (it becomes lib_foo = {version = "0.2.0", path = "../lib_foo"}
). When using the second method (workspace level patch), the dependency requirement remains lib_foo = "0.1.0"
. The expected behavior is for cargo set-version
to set it to lib_foo = "0.2.0"
.
In general, if a crate has a workspace-internal dependency before cargo set-version
, then this dependency should be updated accordingly.
Reproduction
I created a repository with reproduction instructions.
There is one binary crate in ./bin
and two library crates ./eternaltwin_config
and ./eternaltwin_core
(I had to reuse the name of one of my libs so crates-io patching works). The dependency on ./eternaltwin_config
uses the first method, the dependency on ./eternaltwin_core
uses the second method. Running cargo set-version 0.2.0
exhibits the issue.