-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Import cargo remove
into cargo
#11099
Conversation
r? @weihanglo (rust-highfive has picked a reviewer for you, use r? to override) |
b797e37
to
471f8d9
Compare
Fixed tests on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not dug through all of the tests but overall, this looks good. None of my comments are blocking.
EDIT: With all of the prep work done, its crazy to see how little code this is
471f8d9
to
e352836
Compare
Something else that might be useful as future work: if the user tries to remove a package that doesn't exist in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With all of the prep work done, its crazy to see how little code this is
Totally agree! Thanks epage so much for previous efforts and cassaundra for posting this PR as well.
tests/testsuite/cargo_remove/optional_dep_feature/out/Cargo.toml
Outdated
Show resolved
Hide resolved
f155447
to
13a2f06
Compare
Fixed all nits that were mentioned, and fixed the lock file test. Tests are failing due to some network error it looks like (edit: working now 🤷♀️). |
13a2f06
to
ed25d6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! No outstanding issue from me. Thank you.
@epage you can r+ it whenever you feel it's about time.
Edited: Oh. I feel like we still need an FCP, no?
Hmm, I thought I fixed it, but the extra space in |
ed25d6b
to
d8b6a39
Compare
Newly added 56918df calls |
@rfcbot fcp merge While this doesn't require insta-stablization like Like with cargo-add, there is work deferred out of this PR
Work has already started on these. So long as merging this PR doesn't happen near the cut to beta, we should be safe deferring these out of this PR (again, like with cargo-add). |
Team member @epage has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
A few questions:
|
Yes
It removes it from I hadn't though of cleaning up profiles, patch, and release. Would you consider that a blocker for merge, a blocker for going to beta, or important but non-blocker that can be put in an issue?
The development happened in cargo-edit testing with released cargo. workspace inheritance will hit stable in 1.64.0 (tomorrow). I figured that rather than blocking the last work and merge on 1.64.0, we could move forward as-is and then implement the workspace inheritance part in cargo |
I'm fine with that and fine with that forcing insta-stablization (since I was proposing that anyways). Would you consider this a blocker for merge or ok if we just move it to the Deferred list. I had already been wondering if it should be in the Deferred list but decided to wait to see what interest there was. |
Extending the GC operation to cover profile, patch, and replace makes sense to me. |
d8b6a39
to
9a92169
Compare
☀️ Test successful - checks-actions |
4 commits in 0b84a35c2c7d70df4875a03eb19084b0e7a543ef..3cdf1ab25dc4fe56f890e8c7330d53a23ad905d3 2022-10-03 19:13:21 +0000 to 2022-10-07 17:34:03 +0000 - fix(test): Distinguish 'testname' from escaped arguments (rust-lang/cargo#11190) - Fix sparse registry lockfile urls containing 'registry+sparse+' (rust-lang/cargo#11177) - doc(features2): polish docs a bit (rust-lang/cargo#11185) - Import `cargo remove` into cargo (rust-lang/cargo#11099)
Update cargo 4 commits in 0b84a35c2c7d70df4875a03eb19084b0e7a543ef..3cdf1ab25dc4fe56f890e8c7330d53a23ad905d3 2022-10-03 19:13:21 +0000 to 2022-10-07 17:34:03 +0000 - fix(test): Distinguish 'testname' from escaped arguments (rust-lang/cargo#11190) - Fix sparse registry lockfile urls containing 'registry+sparse+' (rust-lang/cargo#11177) - doc(features2): polish docs a bit (rust-lang/cargo#11185) - Import `cargo remove` into cargo (rust-lang/cargo#11099)
Update cargo 4 commits in 0b84a35c2c7d70df4875a03eb19084b0e7a543ef..3cdf1ab25dc4fe56f890e8c7330d53a23ad905d3 2022-10-03 19:13:21 +0000 to 2022-10-07 17:34:03 +0000 - fix(test): Distinguish 'testname' from escaped arguments (rust-lang/cargo#11190) - Fix sparse registry lockfile urls containing 'registry+sparse+' (rust-lang/cargo#11177) - doc(features2): polish docs a bit (rust-lang/cargo#11185) - Import `cargo remove` into cargo (rust-lang/cargo#11099)
Add completions for `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of #11099 by adding bash and zsh completions for the cargo remove subcommand. ### How should we test and review this PR? There doesn't seem to be much in the way of testing for these completions automatically, so I would suggest verifying that they work in practice and sufficiently cover the subcommand's surface area. ### Additional Information I will also soon post a PR for cargo remove's documentation.
…anglo Add completions for `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of rust-lang#11099 by adding bash and zsh completions for the cargo remove subcommand. ### How should we test and review this PR? There doesn't seem to be much in the way of testing for these completions automatically, so I would suggest verifying that they work in practice and sufficiently cover the subcommand's surface area. ### Additional Information I will also soon post a PR for cargo remove's documentation.
Document `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of #11099 by adding documentation for the cargo remove subcommand. ### How should we test and review this PR? Ensure that the documentation renders correctly and appropriately covers the feature.
Document `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of #11099 by adding documentation for the cargo remove subcommand. ### How should we test and review this PR? Ensure that the documentation renders correctly and appropriately covers the feature.
Document `cargo remove` ### What does this PR try to resolve? This PR continues the deferred work of #11099 by adding documentation for the cargo remove subcommand. ### How should we test and review this PR? Ensure that the documentation renders correctly and appropriately covers the feature.
Clean up workspace dependencies after cargo remove ### What does this PR try to resolve? After successful removal of an inherited dependency from a workspace member, clean up the root workspace manifest. This PR is part of the continued working on cargo remove (#11099, see deferred work). ### How should we test and review this PR? Make sure the tests cover all possible use cases. After posting this PR, I will post a short self-review regarding some design concerns. ### Additional information #11194 is currently blocked on this feature.
I just want to point out that a dependency can now be removed with the |
@jujpenabe. Nice catch. I just created an issue #11348 for it. |
Clean profile, patch, and replace in cargo remove ### What does this PR try to resolve? This PR is part of the continued work on cargo remove (#11099, see deferred work). After a successful removal of a dependency, clean up the profile, patch, and replace sections to remove all references to it. **Note** the GC process was expanded to clean up not just references to the dependencies just removed, but also references of all dependencies. This was because there's not an easy way to determine which dependencies correspond to the given TOML keys, without either 1) figuring that out before the removal (therefore having to predict the behavior), or 2) returning that information from the remove function (somewhat unorthodox for an op). ### How should we review and test this PR? Verify that the implementation makes sense and that the tests are sufficient.
fix(add): Reduce the chance we re-format the user's `[features]` table ### What does this PR try to resolve? #11743 pointed out that we re-format the users `[features]` table when running `cargo add` which was a bug introduced in #11099. This reduces the chance people will run into this problem - Reducing the scope of the `fmt` call - Preserving formatting in a simple case Actually removing the `fmt` case can make some common formatting cases more complex to do "right", so I'm punting on that for now. ### How should we test and review this PR? Look at the individual commits as I show how each change improves the behavior of `cargo add`.
What does this PR try to resolve?
This PR merges
cargo remove
from cargo-edit into cargo.Motivation
With #10472, cargo-add was added to cargo. As part of that discussion, it was also proposed that
cargo rm
(nowcargo remove
) eventually be added as well.Drawbacks
Behavior
cargo remove
operates on one or more dependencies from a manifest, removing them from a specified dependencies section (using the same flags ascargo-add
) and from[features]
activations if the dependency is optional. Feature lists themselves are not automatically removed when made empty. Like with cargo-add, the lock file is automatically updated.Note: like
cargo add
,cargo remove
refers to dependency names, rather than crate names, which can be different with the presence of thename
field.Note:
cargo rm
has been renamed tocargo remove
, based on prior art and user feedback (see discussion). Although this renaming is arguably an improvement, adding anrm
alias could make the switch easier for existing users of cargo-edit (at the cost of a naming conflict which would merit insta-stabilization).Help output
Example usage
How should we test and review this PR?
This is following the pattern from cargo-add which was implemented in three different PRs (implementation, documentation, and completions), in the interest of reducing the focusing discussions in each PR and allowing cargo-add's behavior to settle to avoid documentation churn.
cargo-add
#10577The remaining changes (documentation and shell completions) will follow shortly after.
Some work has already begun on this feature in #11059.
Work on this feature was carried out on the
merge-rm
branch of cargo-edit with PRs reviewed by @epage. If you are interested in seeing how this feature evolved to better match cargo's internals, you might find the commit history there to be helpful. As this PR is reviewed, changes will be made both here and on that branch, with the commit history being fully maintained on the latter.cargo remove
is structured like most other subcommands:src/bin/cargo/commands/remove.rs
contains the cli handling and top-level execution.src/cargo/ops/cargo_remove.rs
contains the implementation of the feature itself.In order to support this feature, the
remove_from_table
util was added toutil::toml_mut::manifest::LocalManifest
.Tests are split out into a separate commit to make it easier to review the production code and tests. Tests have been implemented with
snapbox
, structured similarly to the tests ofcargo add
.Prior art
poetry remove
yarn remove
pnpm remove
go get
go get foo@none
to removepkg rm
--all
to remove all dependenciesbundle remove
dart pub remove
luarocks remove
Uninstall-Package
haxelib remove
raco pkg remove
Insta-stabilization
In the discussion of
cargo add
's stabilization story (Zulip stream), it was brought up that the feature might benefit from being insta-stabilized to avoid making the cargo-edit version of the binary hard to access. Sincecargo rm
(from cargo-edit) was renamed tocargo remove
here, such a conflict no longer exists, so this is less of a concern.Since this feature is already has a had a long run of user testing in cargo-edit and doesn't have unsettled UI questions like cargo-add did, it might still be a candidate for insta-stabilization.
Deferred work
Necessary future work:
cargo remove
#11227)cargo remove
#11204)It was found in the review of
cargo add
that it was best to defer these first two items to focus the discussion and as there was still behavior churn during the review of cargo-add.Future Possibilities
The following are features which we might want to add to
cargo remove
in the future:cargo rm
alias to ease transition for current cargo-edit userscargo rm --unused
killercup/cargo-edit#415Additional information
Fixes #10520.