cargo: A way for users to bulk upgrade across incompatible versions
Problem
A lot of incompatible upgrades have a small enough of breakages that a “upgrade all of my incompatible version requirements” would make it easier to go through this process.
This is currently exposed in the cargo upgrade command
Proposed Solution
Tasks
- update breaking
- #13979
- Test cases for
cargo update --breaking only-compatible renamed non-semver-operator transitive-dep
- Test cases for
-
--precise <breaking> - Call for testing
- Stabilization
- #13979
- #12544
- #12614
- #13372
- #12545
- bugs and identified tasks
Deferred
- Modifying version requirements for compatible upgrades
See https://github.com/rust-lang/cargo/issues/12425#issuecomment-1659453818
Previously, https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/141
Unresolved questions
- Flag name
--breakingto focus on semver (as this is limited to^)--incompatibleapplies to all version req operators and doesn’t have a good short flag (-iis generally assumed to be “interactive”)- Dart calls it
--major-versionsthough we have the issue of “absolute major” (x.0.0) and "relative major (also0.x.0,0.0.x).- budler calls it
--major
- budler calls it
- pnpm calls it
--latestbecause of a “latest” tag
Notes
Related
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 24
- Comments: 43 (29 by maintainers)
Commits related to this issue
- Auto merge of #12428 - epage:update, r=weihanglo fix(update): Tweak CLI behavior ### What does this PR try to resolve? When looking at `cargo update` for #12425, I noticed that the two flags relate... — committed to rust-lang/cargo by bors 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forward arguments to another command, like `cargo test`. I... — committed to epage/cargo by epage 3 years ago
- Auto merge of #12545 - epage:positional, r=weihanglo fix(update): Make `-p` more convenient by being positional Generally, cargo avoids positional arguments. Mostly for the commands that might forw... — committed to rust-lang/cargo by bors 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo u... — committed to epage/cargo by epage 3 years ago
- Auto merge of #12544 - epage:recursive, r=weihanglo fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and nam... — committed to rust-lang/cargo by bors 3 years ago
- Auto merge of #12591 - epage:spec, r=weihanglo Prepare for partial-version package specs ### What does this PR try to resolve? These are refactorings, test expansions, and cleanups I saw as I was p... — committed to rust-lang/cargo by bors 3 years ago
Having been fairly involved in this discussion via the internals thread, I’m happy to see this move forward in a direction that I wholeheartedly support. @epage thanks for pushing this forward!
And just to have this all in the same place, from https://github.com/rust-lang/cargo/issues/14178#issuecomment-2275791649:
Perhaps that’s better as
2.0.0-beta.1to3.0.0? That way you have to opt into each pre-release series, but you never “skip over” a chance to return to stable?So this upgrading between pre-releases only happens when all of the pre-releases have that same MAJOR, MINOR, and PATCH versions, and otherwise it looks for a newer stable version to upgrade to?
Isn’t this the last checkbox of https://github.com/rust-lang/cargo/issues/12425#issuecomment-2186198258?
From what I understand of the current semantics, they are what they should be.
--breakingis a “force” flag to update a dependency when a^operator would otherwise prevent the update.At this time, updating through pre-releases is not a breaking change, so
--breakingdoes not apply (see #6016, #2222, #3263). If you work around that with=, then--breakingstill does not apply.To update pre-releases that use
^, then we need the feature that is left out of this Issue, a way to bump the minimum of version reqs to what is in the lockfile (see #10498).cargo update --breakingshould not change compatible version requirementscargo update --breakingshould not change compatible version requirementsWe need to clarify the semantics for how to handle this case
I reckon we should try to stick to semver’s rules here (https://semver.org/#semantic-versioning-specification-semver):
Personally I don’t know if we took the right approach to pre-releases in #14250 — I left more of a comment on that issue (https://github.com/rust-lang/cargo/issues/14178#issuecomment-2275688972), but my overall proposal is:
This, what I would consider a bug, showed up with
derive-morewhencargo upgrade --breakingfirst failed to upgrade from1.0.0-beta.6to1.0.0-beta.7, and again (more egregiously) from1.0.0-beta.7to1.0.0.Let me know if I’m misguided here / if you’d like me to try to submit a PR!
The non-breaking update does not fail, but outputs something like this:
The breaking update currently only outputs this:
So maybe the breaking one should add:
as well as a feature to list the other packages using
--verbose?@VorpalBlade I just ran into the same issue as you, seems like updating non-breaking versions (https://github.com/rust-lang/cargo/issues/12425#issuecomment-2211987113) is now being tracked here: https://github.com/rust-lang/cargo/issues/10498.
Yes, I agree the logic should be:
(Note that even though I’m writing that, that’s not what I would like to use. I would like something like #14372. But it could be a separate flag.)
And would agree with @djc that moving to a higher version is better than taking into account age — though really there should probably be a lint for anyone trying to push a lower prerelease version than is already published (if there isn’t already?)
I would say yes. If you decide to go with a prerelease, it usually means you want the latest thing. Also, I remember having read somewhere that prereleases are incompatible between each other, so
--breakingshould bump to the latest because each version is incompatible.I think all of those should be in scope for
--breaking.For my use case of
cargo upgrade(whichcargo update --breakinghas been advertised as a replacement of) this would be the mode I want. I’m fine with it being an optional flag to do so, but currentlycargo update --breakingis a step back functionality wise (performance is of course better though).Quoting myself from https://github.com/rust-lang/cargo/issues/14204 (apparently @epage prefers feedback in this issue instead):
As such it seems I will probably have to port cargo-upgrade from cargo-edit to sparse registry myself at some point. When and if I have time. As
cargo update --breakingjust doesn’t cut it for my use case.That is covered in https://github.com/rust-lang/cargo/issues/12425#issuecomment-1659453818
This bug will need a separate PR: https://github.com/rust-lang/cargo/pull/14049#discussion_r1636021228
We cover those for
cargo update --breakingbut I’m not seeing those covered forcargo update --breaking [SPEC]. We only testjust-foo shared wswhich are all candidates for upgrading. I’m concerned about the semantics of a user explicitly naming a package that--breakingdoesn’t apply to.It might also be of interest to have a mixed workspace, where one package depends on
renamedwithout a rename while another depends on it with a rename. This would need to be a separate test as this wouldn’t error but the other case could potentially (depending on what semantics we want to give it)Yes, I believe the feature as specified says we shouldn’t do compatible updates. We probably want the semantics of
cargo checkafter editingCargo.tomlin case a requirement change causes a cascade of compatible updates.The other problem with modifying the manifests before anything else is that we will leave the workspace in a half-updated state on failure.
My assumption was that we’d edit the
Dependencys for workspace members (maybe all path sources?) and on success, we’d find allCargo.tomlall dependency blocks, includingworkspace.dependencies, and edit them then.FYI on zulip I brought up the idea of a
pedanticmachine-applicable (ie--fixable) lint to flag imprecise dependencies.Yes, we’d update the version requirement, if an incompatible version exists, and then run the normal code.