-
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
cargo install --dry-run #11123
Comments
This is a feature to pursue. We can make it as an unstable feature behind |
Just thought about this and it would seem nice indeed. My personal use case would be to be able to detect whether a package needs:
or something along those lines, as long as it has the necessary information, at least these. Indeed, if I'm not mistaken, the Although it not high priority for me either, as the buggy version check that I currently have based on |
Hey @PaulDance. Thanks for being interested in this. Thinking backwards from what users want, here is my idea that the initial version of
There might be somethings hard to do in the first PR, like programming interface for scripting, or checking if yanked versions will block the installation. That's fine, since we plan to put it behind For the implementation, it might not be as easy as it looks like at first glance. It depends on how acurate we want for
If you have any question, find us on Zulip t-cargo or in the office hours. Cheers! |
@weihanglo I think I'm missing where you are going with talking about |
For querying the state (needs install, needs update, updated), we have the data ( |
To learn where Cargo will install the binaries, we need output infos that are computed in |
claim first, question it later~ @rustbot claim |
As long as it ends up being implemented with things I care for or that I could add easily, I don't mind, please go ahead. I simply didn't find the time for it yet. |
hi~, If there are any good implementations and plans, I'd love to see them happen. |
Wouldn't the standard error stream's content be enough to achieve this for now, even if there wouldn't be any stability guarantee?
These would be better indeed, but as you said, they might take a while. I'm therefore looking for some middle ground that could be easier and quicker to integrate in the meantime. |
@rustbot claim |
Was going to comment on #13598 but as this is on more fundamental requirements, posting it here. We have a couple different points where we can stub out behavior for dry-run
Install is more complete at the cost of more time to perform (and less invasive). The challenge is each user might come to dry-run with different needs. In terms of precedence, we do the full work in |
@PaulDance are you still working on this? |
Not at the moment, no, sorry. You can probably unassign me from here and close the PR since a full rewrite is required anyway. |
@rustbot claim |
Add a `--dry-run` flag to the `install` command ### 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.
Call for testing
Basic steps:Requirements:
Try In particular, consider
Please leave feedback on this issue |
From the few simple tests I conducted, things seem to work fine 🙂 |
In the case where a package needs to actually be installed or updated, the crates are in fact really downloaded and not just printed as such, right? If so, would it be possible to make it so that the same lines would be printed without actually downloading the crates or would it be too complicated to achieve in this iteration? Just looking to add a little speed without sacrificing end result information. |
We need to download to discover what bins are present. A general question though is what level of fidelity/reporting do people want from this? For example, yank or msrv messages will only show with a compilation. |
For the top crate or for all? I would have guessed that after downloading the requested crate and locking the dependencies, downloading the dependencies would be optional. |
True but that still runs into the second half of my comment. |
My personal use case would be to determine whether something needs to be done or not. What exactly needs to happen is not of importance for me, in this first iteration at least. Fidelity is not that important for me in this regard and I would therefore be fine with Cargo only printing that it downloaded some crates while it actually did not, which should be compatible with the notion of dry run. This way, the level of reported information should stay the same while it just goes a little bit quicker. I'll let others comment on what exactly they would need, though. For example, what happens after the downloads is not simulated at all. That part may be easier to achieve once the build plan feature lands, if I remember correctly at least. |
A middle-ground solution could be that we switch |
--dry-run
is an important feature for commands with side effects to helpTesting instructions: #11123 (comment)
The text was updated successfully, but these errors were encountered: