# Feedback on \`cargo-upgrade\` to prepare it for merging

**URL:** <https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101>\
**Category:** cargo\
**Created:** [July 29, 2022, 5:08pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101 "2022-07-29T17:08:43Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [August 29, 2022, 2:35pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/61 "2022-08-29T14:35:09Z")

</div>

> [@josh](#):
>
> > [@epage](#):
> >
> > I will say that just because cargo/rust today doesn't help with testing minimum version ranges, I don't think we should abandon keeping them low. There is an unstable feature to use minimum versions for requirements.
> 
> I don't think we should attempt to push that on users of a new tool or new functionality of an existing tool, if those users are not passing such an option. Minimal versions is something you can opt into, with a great deal of challenge as you'll be debugging other people's dependency versions.

To clarify, my point was that minimal version handling is a wider problem with multiple, potentially overlapping solutions that we should all keep in mind rather than designing `cargo upgrade` around being the only solution. I see it as an input to the discussion but not a requirement.

As for the problems of `--minimal-versions`, I do call out the problem with it today and mentioned the proposed replacement ([`--minimal-versions-for-me-but-not-my-dependencies`](https://github.com/rust-lang/cargo/issues/5657) as the tracking issue puts it)

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [August 29, 2022, 11:13pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/62 "2022-08-29T23:13:48Z")

</div>

(this is kinda repeating myself but I do feel like this is a better formulation) As far as `--minimal-versions` goes, imho `cargo update --save` should keep the same default maximal version resolution as `cargo update`; iow `cargo update --save` should put the same version in the lockfile and the manifest. This is today's `cargo update && cargo upgrade --to-lockfile`.

I understand the logic behind not updating the manifest unnecessarily, but the version selection logic should be the same in both modes.

If you want to keep versions low, you use `cargo update --minimal-for-me --save`.

---

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [August 30, 2022, 4:48pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/63 "2022-08-30T16:48:31Z")

</div>

I'm not sure if multiple modes of operation of `cargo update`, with multiple additional switches, are ultimately easier to understand than separate `update` and `upgrade` commands. Similarity of `update` and `upgrade` is unfortunate, but OTOH it allows the two commands to have different default behaviors without seeming inconsistent.

---

<div class="post-metadata">

**Author:** ![kpreid](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kpreid/32/8484_2.png) [@kpreid](https://internals.rust-lang.org/u/kpreid)\
**Post date:** [August 31, 2022, 4:57am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/64 "2022-08-31T04:57:02Z")

</div>

Perhaps clarity would be improved by not trying to pack the meaning into single English words (whether they are `update` and `upgrade` or not). What if the extra command was named `cargo major-update`? That communicates immediately that it is “`update` but moreso”, and to those familiar with semver, roughly what it does.

---

<div class="post-metadata">

**Author:** ![crawfish-storeroom](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/crawfish-storeroom/32/9820_2.png) [@crawfish-storeroom](https://internals.rust-lang.org/u/crawfish-storeroom)\
**Post date:** [September 9, 2022, 12:54am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/66 "2022-09-09T00:54:08Z")

</div>

as reqested in one of the following posting these here for transparency.

as is upgrade doesnt work and reported by multiple users with full steps to repro. tried multiple ways based on @epage feedback but didnt get toml updates, even with an update first. downgrading many version does work as expected and documented

- [`cargo upgrade` doesn't any more (regression) · Issue #761 · killercup/cargo-edit · GitHub](https://github.com/killercup/cargo-edit/issues/761)
- [no longer upgrading toml files · Issue #784 · killercup/cargo-edit · GitHub](https://github.com/killercup/cargo-edit/issues/784)

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 1:37am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/67 "2022-09-09T01:37:38Z")

</div>

Do you have any feedback on the proposed new behavior for cargo-upgrade? I understand that some people find the existing behavior confusing. We are wanting more input on the new behavior to make sure people are not unpleasantly surprised when it next changes.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 3:48am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/68 "2022-09-09T03:48:00Z")

</div>

I'm starting to play with what was discussed here with the twist: I'm making the tweaks as-if `cargo upgrade` will replace `cargo update` to collect feedback on the "ideal" so we can consider how we might scale back if needed.

Current changes in `master`:

- [Only work on the full workspace](https://github.com/killercup/cargo-edit/pull/785)
- [Always upgrade compatible dependencies](https://github.com/killercup/cargo-edit/pull/786)
- [Implement `--recursive=<bool>`, a different take on `--aggressive`](https://github.com/killercup/cargo-edit/pull/787)
- [Use crate names rather than dependency names](https://github.com/killercup/cargo-edit/pull/788)

Some items remaining

- ~~[No equivalent of `--precise`](https://github.com/killercup/cargo-edit/issues/790)~~ (and [no `--precise` for indirect dependencies](https://github.com/killercup/cargo-edit/issues/797))
- ~~[Need to reproduce `update`s handling of git dependencies](https://github.com/killercup/cargo-edit/issues/792)~~
- How to select incompatible vs compatible

I had a couple of ideas for incompatible vs compatible.

The sets of dependencies to touch falls in

- Compatible
- Incompatible
- Pinned

Proposal 1: Mutually exclusive modes

- Compatible by default, disable if another flag is set
- Incompatible opt-in with `--incompatible`, error if `--pinned` is also set
- Pinned opt-in with `--pinned`

Proposal 2: Additive modes with a default if none specified

- Compatible by default, require `--compatible` if another flag is specified
- Incompatible opt-in with `--incompatible`
- Pinned opt-in with `--pinned`

(open to feedback on which is the default in either)

For context, some others:

`master` behavior

- Compatible always done
- Incompatible always done
- Pinned opt-in with `--pinned`

Roughly what was talked about earlier in this thread

- Compatible always done
- Incompatible opt-in with `--incompatible`
- Pinned opt-in with `--pinned`

---

<div class="post-metadata">

**Author:** ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)\
**Post date:** [September 9, 2022, 11:17am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/69 "2022-09-09T11:17:48Z")

</div>

> [@epage](#):
>
> Proposal 1: Mutually exclusive modes
> 
> - Compatible by default, disable if another flag is set
> - Incompatible opt-in with `--incompatible`, error if `--pinned` is also set
> - Pinned opt-in with `--pinned`
> 
> Proposal 2: Additive modes with a default if none specified
> 
> - Compatible by default, require `--compatible` if another flag is specified
> - Incompatible opt-in with `--incompatible`
> - Pinned opt-in with `--pinned`

Both of these proposals seem to treat "both compatible and incompatible" as the more unusual case, rather than a common case. (I do think only upgrading compatible versions is the right default (even if we switch commands), though.)

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 11:51am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/70 "2022-09-09T11:51:28Z")

</div>

> [@josh](#):
>
> Both of these proposals seem to treat "both compatible and incompatible" as the more unusual case, rather than a common case. (I do think only upgrading compatible versions is the right default (even if we switch commands), though.)

Looks like I left out part of my motivation and some alternatives: I was exploring alternatives to having a negative flag like `--no-compatible`, `--compatible=false`, `--skip-compatible`, or `--only-compatible` for when someone wants to only upgrade breaking changes.

We've also talked of `--minimal-for-me` but there are unknowns around that and I do worry that it be confusing to have a flag that is --minimal-for-me` that then bumps major as that is a bit contradictory, depending on how well we can document it.

---

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [September 9, 2022, 11:53am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/71 "2022-09-09T11:53:54Z")

</div>

Could "incompatible" be the default? This is the behavior I expect from upgrades.

~~Then perhaps "compatible" could be `--minor`?~~

Or maybe even compatible left to `cargo update` exclusively, e.g. `cargo update --save`.

---

<div class="post-metadata">

**Author:** ![crawfish-storeroom](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/crawfish-storeroom/32/9820_2.png) [@crawfish-storeroom](https://internals.rust-lang.org/u/crawfish-storeroom)\
**Post date:** [September 9, 2022, 12:04pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/72 "2022-09-09T12:04:32Z")

</div>

my feedback is to restore the expected and documented behavior from 0.9.1 which match what is stated in documentation and help. otherwise it doesnt match and confusion is expected. multiple user also suggest the same from the linked issues so its not the users being confused imo.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 12:04pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/73 "2022-09-09T12:04:58Z")

</div>

On the exact defaults, I am open to ideas. My proposal was more meant to focus on the mechanism for customizing the default.

The reason I started off with compatible being the default is that is more like `cargo update` today and I was writing everything as-if `cargo upgrade` superseded `cargo update`.

EDIT: And my concern with calling the flag `--minor` is that refers to "major.minor.update" but compatible could take many shapes, like `0.breaking.compatible`.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 3:54pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/74 "2022-09-09T15:54:12Z")

</div>

Something I feel that has been missing in this conversation (my fault) is a summary of all of the use cases we are considering addressing so we can make sure we are all on the same page and can consider how different proposals line up with them

I've tried to capture the main points. Let me know if I missed any!

- Separate `cargo update` (for lock file) and `cargo upgrade` (for manifest) commands is confusing to some users
- Some application authors want to upgrade to get the latest bug fixes and features
- Some library authors want to keep up on breaking changes but otherwise want to keep version requirements low to allow dependents to choose the version right for them (lower audit churn with fewer upgrades, workaround bugs, MSRV, etc)
- Frequently, users will want to defer certain breaking changes because of the level of churn or missing functionality
- Users need to be able to force a specific minimum version (and test with it) for MSRV or another need
- Crate authors want their manifest to match their lockfile to ensure that they do not accidentally use new functionality that breaks their users building with an old version.
  - [minimal (direct?) versions](https://github.com/rust-lang/cargo/issues/5657) is another tool in solving this
  - Stablizing `#[stable]` attributes and warning when an API item newer than the minimal version is being used is another tool for solving this problem

- Crate authors want to be able to test out their changes (either a `--dry-run` to opt-out of changes or a `--save` to opt-in)
- Crate authors want to script checking if there are any breaking changes (by checking the exit code)
- Sometimes crate authors need to constrain (or pin) a dependency to workaround a problem and need to specifically decide when to modify the extra constraints
- Sometimes crate authors need to rename a dependency to access an old version and a new version at the same time and don't want to upgrade the old version to the new version, negating its purpose
- Some crate authors specifically chose their version requirement precision while authors want to ensure they use full precision always

(the initial post has been updated with this list)

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [September 9, 2022, 4:35pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/75 "2022-09-09T16:35:58Z")

</div>

Minor note: instead of and/or in addition to the heuristics, the Cargo manifest could get additional keys to control how `update`/`upgrade` functions.

e.g. even just `na = { package="nalgebra", version="0.31.1", pinned=false }` would be useful/interesting, or `package.update.precision = "full"`, or lots of other knobs which could be persistent in the manifest rather than ephemeral CLI flags.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 7:04pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/76 "2022-09-09T19:04:57Z")

</div>

Before I forget some of my ideas, I've gone ahead and re-wrote the proposal (mostly matches cargo-edit master branch) and listed higher-level alternatives. This was a rough first pass, more detail is needed both in how the different options would work and on the trade offs.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 9, 2022, 7:34pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/77 "2022-09-09T19:34:30Z")

</div>

Was re-reading [clig.dev](https://clig.dev/#subcommands) and just saw this

> **Don’t have ambiguous or similarly-named commands.** For example, having two subcommands called “update” and “upgrade” is quite confusing. You might want to use different words, or disambiguate with extra words.

That cuts.

---

<div class="post-metadata">

**Author:** ![djc](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/djc/32/1592_2.png) [@djc](https://internals.rust-lang.org/u/djc)\
**Post date:** [September 14, 2022, 8:36am UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/78 "2022-09-14T08:36:52Z")

</div>

Yeah, I think that's a very good high-level reason to keep `update` and `upgrade` functionality in the same command, distinguished by options (or, supposedly, nested subcommands? git has them but I know that others don't like them).

As a code reviewer, I would still like to have separate workflows for updating across semver-breaking versions vs non-breaking versions, since I feel that semver-breaking updates deserve a bit more scrutiny at review time.

---

<div class="post-metadata">

**Author:** ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)\
**Post date:** [September 14, 2022, 10:08pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/79 "2022-09-14T22:08:13Z")

</div>

- The `--incompatible` vs `--compatible false` distinction is _very_ subtle. Without the manual I could not guess what they do.

- defaulting to whole workspace is nice (saves me from typing longish `--workspace`), and feels consistent with workspace-wide `Cargo.lock`.

- update of `Cargo.lock` with upgrade is also very welcome, as I always ran `cargo update` afterwards anyway.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 14, 2022, 10:14pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/80 "2022-09-14T22:14:08Z")

</div>

To make this conversation more concrete, I've gone ahead and updated `cargo-upgrade` to one combination of proposals.

See [Release v0.11.0 · killercup/cargo-edit · GitHub](https://github.com/killercup/cargo-edit/releases/tag/v0.11.0) for more details.

---

<div class="post-metadata">

**Author:** ![epage](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/epage/32/3171_2.png) [@epage](https://internals.rust-lang.org/u/epage)\
**Post date:** [September 14, 2022, 10:15pm UTC](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101/81 "2022-09-14T22:15:50Z")

</div>

> [@kornel](#):
>
> The `--incompatible` vs `--compatible false` distinction is _very_ subtle. Without the manual I could not guess what they do.

Very good point. Unsure if its just the curse of knowledge/familiarity that I hadn't noticed this.

Any thoughts on how to allow control over the different types of upgrades? I feel like `--no-compatible` would be the same or worse.

[Previous page](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101.md?page=3)

[Next page](https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101.md?page=5)
