Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A setting and/or flag to add short version numbers with cargo add #12072

Closed
docwilco opened this issue May 1, 2023 · 3 comments
Closed

A setting and/or flag to add short version numbers with cargo add #12072

docwilco opened this issue May 1, 2023 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@docwilco
Copy link

docwilco commented May 1, 2023

Problem

Currently, cargo add will add full latest version number to Cargo.toml. Especially in new projects (where a lot of add actions happen,) this might not be ideal. I at least, find myself removing patch and ofteneven minor version numbers, so that I can occasionally just remove Cargo.lock and get everything upgraded.

Proposed Solution

[add]
version-specificity="major"

resulting in cargo add tokio adding

[dependencies]
tokio = "1"

and

[add]
version-specificity="minor"

resulting in cargo add tokio adding

[dependencies]
tokio = "1.28"

Possible settings major|minor|patch with patch being the default.

Not quite sure about commandline flags, am absolutely open to suggestions there.

Notes

I am absolutely open to writing a PR for this.

@docwilco docwilco added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels May 1, 2023
@epage
Copy link
Contributor

epage commented May 1, 2023

Before anything else I want to check in on the motivation

Currently, cargo add will add full latest version number to Cargo.toml. Especially in new projects (where a lot of add actions happen,) this might not be ideal. I at least, find myself removing patch and ofteneven minor version numbers, so that I can occasionally just remove Cargo.lock and get everything upgraded.

Why do you need to change your version requirement to upgrade? The version requirement is saying "at least x.y.z but not more than x+1.0.0. cargo update and rm Cargo.lock will both allow updating any of your dependencies, independent of the version requirement.

@epage
Copy link
Contributor

epage commented May 1, 2023

For some background, when we merged cargo add (see #10472), one of the concerns was

  1. This is a high UX feature that will draw a lot of attention (ie Issue influx)

e.g.

Note: killercup/cargo-edit#126 is very similar to your request

To reduce this, we explicitly decided:

We've tried to reduce the UX influx by focusing the scope to preserving semantic information (custom sort order, comments, etc) but being opinionated on syntax (style of strings, etc)

@docwilco
Copy link
Author

docwilco commented May 1, 2023

Aha, OK, I totally missed that bit. My apologies for wasting your time!

@docwilco docwilco closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants