-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Warn when installing with a non-default toolchain #16131
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
base: master
Are you sure you want to change the base?
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use |
2157847 to
9006944
Compare
weihanglo
left a comment
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.
EDIT: The force push was to make Clippy happy.
Feel free to force-push and re-organize your commits during the iterations.
5f2fbb4 to
c64e01a
Compare
This comment has been minimized.
This comment has been minimized.
c64e01a to
f0f222f
Compare
|
Just FYI, I know it looks like only some of the comments have been addressed. I am still hoping to get feedback on #16131 (comment) and #16131 (comment). |
f75ccb8 to
a386ddd
Compare
|
I resolved comments that I thought I implemented uncontroversially. I hope that was okay. EDIT: I also hid a few of my own comments that were old. |
|
Please clean up your commits for how they should be reviewed and merged, rather than for how it was developed. |
13bd099 to
2e97d39
Compare
|
I think the PR is ready to be looked at again. |
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
2e97d39 to
79a32f6
Compare
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
Thought of this when reviewing new cases for `std::env` in rust-lang#16131.
### What does this PR try to resolve? Thought of this when reviewing new cases for `std::env` in #16131. ### How to test and review this PR?
This is the first of several commits to implement a fix for rust-lang#11036. The changes fetch the `RUSTUP_TOOLCHAIN_SOURCE` environment variable set by Rustup, and warn if it is anything other than "default" or "cli".
79a32f6 to
a106b1d
Compare
|
I need to fix the commits. I will do that within the next few hours. |
a106b1d to
bd62811
Compare
|
The commits should be fixed now. |
src/cargo/ops/cargo_install.rs
Outdated
| fn is_default_or_cli_override(&self) -> Option<bool> { | ||
| match self { | ||
| Self::Default => Some(true), | ||
| Self::Environment => Some(false), | ||
| Self::CommandLine => Some(true), | ||
| Self::OverrideDB => Some(false), | ||
| Self::ToolchainFile => Some(false), | ||
| Self::Other(_) => None, | ||
| } | ||
| } |
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.
Instead of enumerating the cases in the function name, can we describe the policy this functions is meant to convey?
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.
is_override_requiring_warning
That doesn't convey any meaning to the caller, requiring them to read the function to understand what is happening
One option is to flip the logic and name it is_implicit_override. I know this variant read better in the caller code but this is the most clear name I can think of to clarify the intent.
bd62811 to
78f7c63
Compare
| let report = &[Level::WARNING | ||
| .secondary_title(format!( | ||
| "default toolchain{maybe_toolchain} implicitly overridden by {source}" | ||
| )) | ||
| .element(Level::HELP.message(format!( | ||
| "use `cargo +stable install` if you meant to use the stable toolchain." | ||
| )))]; |
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.
in thinking over the warnings message in #16131 (comment), I'm wondering novice users will realize why this is a concern or why this is happening.
One thought is adding:
note: rustup selects the toolchain based on the parent environment and not the environment of the package being installed
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 implemented this. Also, I removed the period from the help message for consistency.
tests/testsuite/rustup.rs
Outdated
| [WARNING] default toolchain `test-toolchain` implicitly overridden by unrecognized source | ||
| | | ||
| = [HELP] use `cargo +stable install` if you meant to use the stable toolchain. |
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.
Isn't RUSTUP_TOOLCHAIN the active toolchain, not the default, making this
[WARNING] default toolchain implicitly overridden to
test-toolchainby unrecognized source
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.
Oof. You're right.
"overridden to test-toolchain" not "overridden with test-toolchain"?
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 went with "with". But I would be happy to change it if you like.
|
Thanks for your patience through the rounds of feedback! This is looking great! |
78f7c63 to
5aee235
Compare
This PR implements the cargo changes for #11036. The rustup changes were implemented in rust-lang/rustup#4518.
The PR is currently organized as four commits:
RUSTUP_TOOLCHAIN_SOURCE. This change is not strictly necessary, but it improves the rustup tests' fidelity.pkgfunction to a location where the next commit can use it.cargo installis invoked with a non-default toolchain, as indicated byRUSTUP_TOOLCHAIN_SOURCE.In the third commit, two significant changes were made to
simulated_rustup_environment:RUSTUP_TOOLCHAIN_SOURCE) before calling the proxied tool.The PR is currently marked as draft because rust-lang/rustup#4518 has not yet been released. Technically, this PR could be merged before then. But testing it with a fixed rustup would seem to make sense.
Nits are welcome.
cc: @epage