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

Add a --dry-run flag to the install command #14280

Merged
merged 3 commits into from
Sep 21, 2024

Conversation

Flowrey
Copy link
Contributor

@Flowrey Flowrey commented Jul 21, 2024

What does this PR try to resolve?

This PR add the --dry-run flag to the cargo install command (see #11123).
I've tried to do the bare minimal for this flag to work without changing anything in the output.

In my opinion, the --dry-run flag should mimic as close as possible the behavior of the normal command to avoid missing potential issue in the normal execution. Currently we're missing information about where the binary will be installed.

Unlike #13598 this PR:

  • Include as much of the compilation process as possible without actually compiling
  • use the information provided by BuildContext instead of InstallablePackage::new
  • in the same way as unit_graph, it add a dry_run to the CompileOptions and return a Compilation::new from the function compile_ws without actually compiling.
  • keeps the output the same rather than adding status messages indicating which very broad actions would be performed
  • remove some warning not relevant in the case of a --dry-run

Like #13598, the version check and crate downloads still occur.

How should we test and review this PR?

The first commit include a unit tests to ensure that no binary is actually installed after the dry run.
There is also a snapshot test that show the diff output of the --help flag.

Additional information

Tests and documentation done in #13598, may be cherry picked into this PR if needed.

@rustbot
Copy link
Collaborator

rustbot commented Jul 21, 2024

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. Command-install S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2024
@Flowrey Flowrey marked this pull request as draft July 21, 2024 09:58
@Flowrey Flowrey force-pushed the dry-run-install branch 4 times, most recently from 0e553f7 to f25a3a0 Compare July 21, 2024 10:55
@Flowrey Flowrey marked this pull request as ready for review July 21, 2024 11:23
tests/testsuite/install.rs Outdated Show resolved Hide resolved
@Flowrey Flowrey force-pushed the dry-run-install branch 4 times, most recently from 9894bbb to 275615b Compare July 22, 2024 19:52
@Flowrey Flowrey force-pushed the dry-run-install branch 2 times, most recently from a1df193 to a332bdc Compare July 24, 2024 19:41
@Flowrey Flowrey requested a review from epage August 18, 2024 07:28
@epage epage force-pushed the dry-run-install branch 3 times, most recently from 4b81fe7 to 36867ee Compare August 27, 2024 19:59
@epage
Copy link
Contributor

epage commented Aug 27, 2024

Note: I tweaked the commits to make this easier to review.

@Flowrey Flowrey force-pushed the dry-run-install branch 3 times, most recently from 3440b31 to e1cbe81 Compare September 1, 2024 07:36
@Flowrey
Copy link
Contributor Author

Flowrey commented Sep 1, 2024

Note: I tweaked the commits to make this easier to review.

Thanks, sorry if i made a mess with the commits 😅

@Flowrey Flowrey requested a review from epage September 10, 2024 19:55
src/cargo/ops/cargo_install.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/build_runner/mod.rs Show resolved Hide resolved
tests/testsuite/install.rs Outdated Show resolved Hide resolved
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! This should be ready to merge.

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 21, 2024

📌 Commit b0e08fc has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 21, 2024
@bors
Copy link
Collaborator

bors commented Sep 21, 2024

⌛ Testing commit b0e08fc with merge d7bffc3...

@bors
Copy link
Collaborator

bors commented Sep 21, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing d7bffc3 to master...

@bors bors merged commit d7bffc3 into rust-lang:master Sep 21, 2024
22 checks passed
@Flowrey Flowrey deleted the dry-run-install branch September 21, 2024 07:38
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 28, 2024
Update cargo

19 commits in eaee77dc1584be45949b75e4c4c9a841605e3a4b..80d82ca22abbee5fb7b51fa1abeb1ae34e99e88a
2024-09-19 21:10:23 +0000 to 2024-09-27 17:56:01 +0000
- Update cc to 1.1.22 (rust-lang/cargo#14607)
- feat: lockfile path implies --locked on cargo install (rust-lang/cargo#14556)
- feat(toml): Add `autolib` (rust-lang/cargo#14591)
- fix: correct error count for `cargo check --message-format json` (rust-lang/cargo#14598)
- test: relax panic output assertion (rust-lang/cargo#14602)
- feat(timings): support dark color scheme in HTML output (rust-lang/cargo#14588)
- feat: add CARGO_MANIFEST_PATH env variable (rust-lang/cargo#14404)
- fix(config): Don't double-warn about `$CARGO_HOME/config` (rust-lang/cargo#14579)
- fix(cargo-rustc): give trailing flags higher precedence on nightly (rust-lang/cargo#14587)
- feat: make lockfile v4 the default (rust-lang/cargo#14595)
- perf: Improve quality of completion performance traces (rust-lang/cargo#14592)
- test: Remove completion tests (rust-lang/cargo#14590)
- feat: Add support for completing `cargo update <TAB>` (rust-lang/cargo#14552)
- test: Migrate remaining with_stdout/with_stderr calls (rust-lang/cargo#14577)
- fix(resolve): Improve multi-MSRV workspaces (rust-lang/cargo#14569)
- chore: Bump MSRV to 1.81 (rust-lang/cargo#14585)
- Add a `--dry-run` flag to the `install` command (rust-lang/cargo#14280)
- fix(resolve): Don't list transitive, incompatible dependencies as available (rust-lang/cargo#14568)
- feat(complete): Upgrade clap_complete (rust-lang/cargo#14573)
@rustbot rustbot added this to the 1.83.0 milestone Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-cli-help Area: built-in command-line help A-documenting-cargo-itself Area: Cargo's documentation A-testing-cargo-itself Area: cargo's tests Command-install S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants