You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A method to update manifest version requirements (like cargo-edit's cargo-upgrade) #10498
I had a crate that was defined in my projects Cargo.toml, it updated the version in the Cargo.lock, but not the Cargo.toml
Proposed Solution
It would be cool if cargo update also updated Cargo.toml if applicable.
Notes
No response
Reacted by Giovanni Bassi, Serge Matveenko, Arkadiusz Piekarz, Felix Bargfeldt, Donovan Glover, Diana, Ed Morley, John T. Wodder II, bubiwahn, Alex Saveau and 4 more
I do not know if there is a dedicated issue for this but I plan to follow up on the cargo-add issue by merging other cargo-edit subcommands, like cargo-rm and cargo-upgrade.
cargo-upgrade is probably the least defined for what it will look like merged with questions like
Should it be a separate command or a flag on cargo-update?
Should --skip-compatible be a default? the only behavior?
Something that someone can do to help is to scour other language packaging tools for existing precedence in how they handle cases like this like the cargo-add PR does.
changed the title [-]Can `cargo update` update a dependency specification in Cargo.toml?[/-][+]A method to update manifest version requirements (like cargo-edit's `cargo-upgrade`)[/+]on Apr 22, 2022
Hmm, this issue is more about cargo update updating both files at once which is a subset of cargo upgrades behavior and might be part of the subset we don't merge immediately, so this probably isn't the best issue for tracking the cargo-upgrade integration
#12425 was created specifically for incompatible version upgrades.
The FCPed proposal intentionally left this use case out
Somewhere between deferred and rejected (speaking for myself): Support in cargo update for writing to the manifest for non-breaking changes, like bulk compatible upgrades of version requirements (ie a -save flag) which was one of our lower priority workflows. A --save flag is more about updating versions for your dependents, which while important for having valid lower-bounds on version requirements, doesn't fit with the existing model of cargo update. Maybe in the future we can find a way to express this in cargo update that fits with how it works or maybe another command can take on this role. We just aren't wanting to distract our efforts for handling most of the use cases to handle this one.
In the past, we talked about a --save flag. As pointed out in that Internals thread, this seems to align with npm update
Note that by default npm update will not update the semver values of direct dependencies in your project package.json, if you want to also update values in package.json you can run: npm update --save (or add the save=true option to a configuration file to make that the default behavior).
This sounds like our case. Not being familiar with that ecosystem, I can't say whether there are semantics differences that could affect its use as prior art.
Not seeing any other relevant prior art from the tools sampled for cargo add (#10472).
Activity
epage commentedon Mar 22, 2022
I do not know if there is a dedicated issue for this but I plan to follow up on the cargo-add issue by merging other cargo-edit subcommands, like cargo-rm and cargo-upgrade.
cargo-upgrade is probably the least defined for what it will look like merged with questions like
--skip-compatiblebe a default? the only behavior?Something that someone can do to help is to scour other language packaging tools for existing precedence in how they handle cases like this like the cargo-add PR does.
Auto merge of #10472 - epage:add, r=ehuss
[-]Can `cargo update` update a dependency specification in Cargo.toml?[/-][+]A method to update manifest version requirements (like cargo-edit's `cargo-upgrade`)[/+]epage commentedon Aug 1, 2023
Hmm, this issue is more about
cargo updateupdating both files at once which is a subset ofcargo upgrades behavior and might be part of the subset we don't merge immediately, so this probably isn't the best issue for tracking the cargo-upgrade integrationepage commentedon Aug 8, 2024
#12425 was created specifically for incompatible version upgrades.
The FCPed proposal intentionally left this use case out
See also https://internals.rust-lang.org/t/feedback-on-cargo-upgrade-to-prepare-it-for-merging/17101
epage commentedon Aug 8, 2024
In the past, we talked about a
--saveflag. As pointed out in that Internals thread, this seems to align withnpm updateThis sounds like our case. Not being familiar with that ecosystem, I can't say whether there are semantics differences that could affect its use as prior art.
Not seeing any other relevant prior art from the tools sampled for cargo add (#10472).
epage commentedon Aug 8, 2024
Potential solutions
Regardless of solution, we need to consider
--saveSemantics:
Cargo.lockto be the minimal version.Naming:
--saveis used bynpm updateWhich packages should be affected?
Workfow impact
Cargo.toml,cargo addchanging a transitive dependency, etc will cause a mismatchcargo add, you wouldn't know you need it until you ran the command and what to name it becomes harder--savewithout doing a dependency updateConfig
Similar to
--savein semantics and in issues. Could also apply tocargo addIf we also do
--save, we need a--no-saveor--save=false--no-flags after I addedcargo addbut I don't remember whereWorkfow impact
Cargo.tomlwill cause a mismatchCargo.tomlmerge conflicts (they are fine blowing awayCargo.lockon conflict)."lockfile higher than version reqs" lint
With a
cargo fixto adjust version reqsDo we go as far as
cargo updateandcargo addseeing the presence of the lint and auto-fixing?cargo fixor not likecargo add,cargo remove, andcargo updateWorkfow impact
Cargo.tomlwill cause a mismatch but users will get a warning about it with a suggestion of a command to fix itCargo.tomlmerge conflicts (they are fine blowing awayCargo.lockon conflict).cargo updateauto-fixing would be a problem but so would--warnings=denycausing their CI to fail, so they probably don't want this as a warningepage commentedon Aug 8, 2024
At #5657 (comment), I bring up an idea that came up in a Cargo team meeting for us to develop this feature in place of
-Zminimal-versions