cargo-workspaces
cargo-workspaces copied to clipboard
Maintain dependency semver ranges when publishing new versions
Hey, I was using cargo-ws to publish a new release and I noticed a unintuitive behaviour where it doesn't keep the semver range I set when it needs to update a dependency. For example let's say we have two crates foo and foo-macros.
foo-macros's Cargo.toml
name = "foo-macros"
---version = "0.2.0"
+++version = "0.2.1"
# …
foo's Cargo.toml
name = "foo"
---version = "0.2.0"
+++version = "0.2.1"
# …
[dependencies]
---foo-macros = { version = "=0.2.0", path = "../macros" }
+++foo-macros = { version = "0.2.1", path = "../macros" }
When I update foo-macros to 0.2.1, cargo-ws will also update foo's dependency of foo-macros and set it from =0.2.0 to 0.2.1 so that the crate can be compiled and published. However this now means that the next time I run cargo ws publish and release 0.2.2offoo-macrosthenfoowill not be updated because0.2.2is semver compatible with0.2.1` which isn't what I want. I want to ensure that both crates are always the same version.
@XAMPPRocky There's an --exact argument just for this usecase.
Right, but my point is that if I have already specified = in my dependency version in my cargo manifest I shouldn’t have to specify --exact, the tool should infer it.
Unfortunately I decided not to do it that way due to design considerations. I wanted all the behaviour to be a bit explicit.
That's unfortunate, I don't really think this is really explicit however more than unintuitive. It would be explicit it if I was asked to pick a semver requirement when publishing. Currently it just incorrectly assumes I want the default x.y.z.
I am thinking about this and what do you think should happen when only some of them have = and others dont?
I would expect that the tool handles it on a case by case basis. If someone's workspace has multiple different semver requirements on the same crate that's their problem in my opinion. If they want to switch to using a single one they can use the --exact flag or an equivalent.
Maybe you are looking for a configuration setting to save this behaviour description? I would have to think on this a bit before I make any changes.
Thanks for creating the issue.