Repository navigation
Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @weihanglo (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @Muscraft |
There was a problem hiding this comment.
Thanks for working on this, and sorry for the long delay in reviewing it. I am slightly unfamiliar with this part of the codebase and have been trying to wrap my brain around these changes.
I think this is a good start, but using only the command-line features for this runs into the issues with dep_name/feat_name that @ehuss brought up in the original issue. From what I can tell, the reason using only the command-line features won't work is that it doesn't take into account features from things like the [dependencies] table, whereas resolve_all_features does. I am not quite sure how we should go about getting a "real" resolve in this case, but it might be good to look into whether there is a way to reuse a resolve from another part of cargo.
| let check_install = |arg_line, expected_bins| { | ||
| cargo_process(arg_line).run(); | ||
| validate_trackers("foo", "1.0.0", expected_bins); | ||
|
|
||
| cargo_process(arg_line) | ||
| .with_stderr_data(str![[r#" | ||
| ... | ||
| [IGNORED] package `foo v1.0.0` is already installed, use --force to override | ||
| ... | ||
| "#]]) | ||
| .run(); | ||
| }; |
There was a problem hiding this comment.
Having the same str![[r#""#]] inside the closure can break the automatic updating of snapshot tests, as far as I remember. It would be better if each had its own.
There was a problem hiding this comment.
Do you mean, make check_install take three arguments, like
check_install("install --no-default-features foo", &["foo"], str![[r#"
...
[IGNORED] package `foo v1.0.0` is already installed, use --force to override
...
"#]]);
check_install("install foo", &["foo", "foo-feat"], str![[r#"
...
[IGNORED] package `foo v1.0.0` is already installed, use --force to override
...
"#]]);
Is there any way to avoid this repetition? str![[]] seems to want only a literal.
| [[bin]] | ||
| name = "foo-e2" | ||
| path = "src/bin/foo-e2.rs" | ||
| required-features = ["e2"] |
There was a problem hiding this comment.
We should probably have a test case for dep_name/feat_name somewhere
There was a problem hiding this comment.
I'll try to get one going. My first attempt produced confusing errors, where the features I defined in "dep" didn't seem to be visible in "foo".
There was a problem hiding this comment.
I just missed that you have to separately declare features with Package::feature. I've added coverage for dep/feat and dep?/feat. Maybe this also helps to clarify the confusion I have about what extra resolution we need for dep/feature syntax?
| } | ||
|
|
||
| #[cargo_test] | ||
| fn check_upgrade_respects_features() { |
| if weak { | ||
| None | ||
| } else { | ||
| Some(dep_name.as_str()) |
There was a problem hiding this comment.
Using only dep_name here throws away the feature portion of dep/feature (/feature)
There was a problem hiding this comment.
I mentioned below, I'm afraid I don't understand the problem. It seemed to me that only the "dep" part would potentially trigger a new binary in the install target.
|
Thanks for the review. I'll do some of the restructuring (make a passing test for the current behaviour first) and see if I can get a test case for dep/featurename as well (I tested it manually but ran into some issues adding a test case the first time). I assume that it is fine to force-push this PR to rewrite its history based on the style comment. But, I have to admit, I still do not understand
Would it be possible to draw up a concrete example of the problem? In my mind, the binaries produced by cargo install depend only on the features selected in the package to be installed. The selected features may get augmented by some implicit dep/feature syntax, which I account for, but my imagination is failing beyond that. Along the same lines, I didn't understand
As I read it, only the dep part was going to affect which binaries would be selected for installation. So it would be very helpful if you could illustrate some concrete dep/feature topology that this PR isn't handling, just because I'm having trouble picturing it myself. |
98397f8 to
f3ba730
Compare
This comment has been minimized.
This comment has been minimized.
Demonstrate the existing cargo install behaviour when some binaries are not produced by the features used for the build. In this case, install of an already-installed package that doesn't provide all possible binaries will rebuild and reinstall, even if the second install won't produce any additional binaries. References rust-lang#8703
Cargo install was computing all possible binaries for a package regardless of the requested features, and would conclude that the installed package was out-of-date if it hadn't installed all binaries, even if the requested features wouldn't actually produce any of the "missing" binaries. Fixes rust-lang#8703
f3ba730 to
3912fb4
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Fixes #8703
What does this PR try to resolve?
Cargo install was computing all possible binaries for a package regardless of the requested features, and would conclude that the installed package was out-of-date if it hadn't installed all binaries, even if the requested features wouldn't actually produce any of the "missing" binaries.
For example, I found this bug because every time I ran
cargo install jj-cliit would rebuild the package. This was because jj-cli can build some optional test/example binaries, but those aren't part of the default feature.How to test and review this PR?
I've added a new test, and also manually checked
cargo install jj-clidoesn't rebuild the package on the second install.