Skip to content

Conversation

rami3l
Copy link
Member

@rami3l rami3l commented Aug 24, 2025

Closes #4445.

@@ -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>,
Copy link
Member Author

@rami3l rami3l Aug 24, 2025

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.

@rami3l rami3l force-pushed the feat/warn-auto-install branch 7 times, most recently from b1d9725 to 8d25c01 Compare August 31, 2025 15:34
@rami3l rami3l marked this pull request as ready for review August 31, 2025 15:34
@rami3l rami3l marked this pull request as draft August 31, 2025 15:42
@rami3l rami3l force-pushed the feat/warn-auto-install branch from 8d25c01 to fedd51c Compare August 31, 2025 15:47
@rami3l rami3l force-pushed the feat/warn-auto-install branch from 39db6e4 to 7ab47c5 Compare September 1, 2025 12:05
@rami3l rami3l requested review from djc and ChrisDenton and removed request for djc September 1, 2025 12:07
@rami3l rami3l marked this pull request as ready for review September 1, 2025 12:07
Comment on lines +283 to +284
// Disable auto installation of active toolchain unless explicitly requested
cmd.env("RUSTUP_AUTO_INSTALL", "0");
Copy link
Contributor

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") {
Copy link
Contributor

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
Copy link
Contributor

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");
Copy link
Contributor

@djc djc Sep 1, 2025

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show that a toolchain download is due to rust-toolchain.toml
2 participants