-
Notifications
You must be signed in to change notification settings - Fork 973
feat(config): warn user if auto-install is enabled #4454
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
@@ -53,15 +53,15 @@ pub(crate) struct Toolchain<'a> { | |||
impl<'a> Toolchain<'a> { | |||
pub(crate) async fn from_local( | |||
name: LocalToolchainName, | |||
install_if_missing: bool, | |||
install_if_missing: impl Fn() -> anyhow::Result<bool>, |
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.
This change is made so that the self.should_auto_install()
call is postponed to L64, and that the false positive in L60 can be suppressed.
b1d9725
to
8d25c01
Compare
8d25c01
to
fedd51c
Compare
…hain::from_local()`
This also ensures that every test case relying on the `RUSTUP_AUTO_INSTALL` config option is explicitly setting it.
39db6e4
to
7ab47c5
Compare
// Disable auto installation of active toolchain unless explicitly requested | ||
cmd.env("RUSTUP_AUTO_INSTALL", "0"); |
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.
Not sure about this. IMO we should keep the defaults in the tests the same way they are when running real-world rustup
, otherwise things get confusing.
} else { | ||
self.settings_file | ||
.with(|s| Ok(s.auto_install != Some(AutoInstallMode::Disable))) | ||
let res = match self.process.var("RUSTUP_AUTO_INSTALL") { |
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.
Suggest not naming this res
(which I usually read as short for result
and expect to be of type Result
) but auto_install
(or maybe auto
).
.settings_file | ||
.with(|s| Ok(s.auto_install != Some(AutoInstallMode::Disable)))?, | ||
}; | ||
if res |
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.
Suggest making this more linear to avoid the messy layout:
if !res {
return Ok(res);
}
let recursing = self.process.var("RUST_RECURSION_COUNT");
if matches!(recursing.as_deref(), Ok("1")) {
return Ok(res);
}
warn!(..);
Ok(res)
Err(_) | Ok("0"), | ||
) | ||
{ | ||
warn!("auto-install is enabled, active toolchain will be installed if absent"); |
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 think this is too strong until we have a clearer plan about how/when we are actually going to disable it by default. So I would only want to show a message when the active toolchain is actually absent, and make it more informational. I do like showing the suggestion on how to disable the behavior!
Closes #4445.