-
Notifications
You must be signed in to change notification settings - Fork 979
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
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
39db6e4
to
7ab47c5
Compare
src/test/clitools.rs
Outdated
// 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.
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.
@djc FYI this line should be a proof, not a requirement: the changes in this commit modulo this line will continue to work even if RUSTUP_AUTO_INSTALL
is set to 1
or not set at all. How about unsetting it here?
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.
Unsetting it seems okay to me, as that should make it similar to the default behavior.
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.
@djc Hmmm technically those fixes did work but now we are creating a lot of noises in the snapshot tests 🤔
I will try to find a way out of this.
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.
@djc How about introducing another env var to remove this warning without disabling auto install?
Update: Okay, I think this means that the evaluation of self.should_auto_install()
is not lazy enough. I'll try to fix that first.
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.
If we ship it like this I am afraid that we will spam the users. How about making it less frequent by using a global flag to ensure it's only printed once per process, and providing an extra flag to disable these messages?
I'm struggle to remember all the context here. Can you be more specific about what you're proposing? (Maybe with some "screenshots"/mock shell transcripts?)
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.
@djc Of course. To elaborate, what I was suggesting is that, while trying to fix this issue, it seemed that the warning message is happening more frequently than necessary, however it isn't, because we now have somewhat surprising behaviors like this:
> # beta is not installed
> RUSTUP_AUTO_INSTALL=1 rustup +beta target remove aarch64-apple-darwin
info: syncing channel updates for 'beta-aarch64-apple-darwin'
info: latest update on 2025-09-28, rust version 1.91.0-beta.4 (aa7859c0d 2025-09-27)
info: downloading component(s)
[...]
... and every time this happens, the warning message will show up with this patch.
I am afraid rectifying this will bring breaking changes, and at the same time, shipping this patch as-is will, as I said earlier, spam the users.
So I am suggesting that, if we want to land this, maybe we should find a way to automatically and/or manually disable these messages:
How about making it less frequent by using a global flag to ensure it's only printed once per process, and providing an extra flag to disable these messages?
For example RUSTUP_AUTO_INSTALL_WARN=0
will stop these messages from showing up, and a static variable static HAS_WARNED_AUTO_INSTALL
will prevent these messages from showing up twice in a single run. I admit these are not very good solutions, but I'm proposing this here so that we might have a direction to move forward. Maybe you have better options in mind? I'd love to hear 👂
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.
because we now have somewhat surprising behaviors like this:
If you mean that the surprising behavior is that a toolchain is installed when a command is invoked to remove a target, I guess we should fix that separately/maybe first?
I am afraid rectifying this will bring breaking changes, and at the same time, shipping this patch as-is will, as I said earlier, spam the users.
I think you've gotten a bit too risk averse after our auto install adventure. But spamming definitely bad.
For example
RUSTUP_AUTO_INSTALL_WARN=0
will stop these messages from showing up, and a static variablestatic HAS_WARNED_AUTO_INSTALL
will prevent these messages from showing up twice in a single run. I admit these are not very good solutions, but I'm proposing this here so that we might have a direction to move forward. Maybe you have better options in mind? I'd love to hear 👂
I'm definitely not excited about an environment variable to "configure" this behavior but static
that will allow for rate limiting this makes sense to me. A little spam might be a good thing incentive to turn off auto installs!
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 you've gotten a bit too risk averse after our auto install adventure.
@djc Yes you can probably say that... Be assured that this behavior is a faithful reproduction of that in the old version:
> docker run --rm -it rust:alpine sh
> rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.81.0 (eeb90cda1 2024-09-04)`
> rustup +beta target remove aarch64-apple-darwin
info: syncing channel updates for 'beta-aarch64-unknown-linux-musl'
1007.6 KiB / 1007.6 KiB (100 %) 567.4 KiB/s in 1s ETA: 0s
info: latest update on 2025-09-28, rust version 1.91.0-beta.4 (aa7859c0d 2025-09-27)
info: downloading component 'cargo'
^C
I still think we should rectify the behavior and I don't mind doing a separate PR first for this, but indeed constantly breaking others' workflow did put me into self-doubt every now and then.
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 don't think it's constantly and when it did happen we figured out a way forward pretty quickly. But, it's definitely time to start planning for a release again so our releases don't get too big. As team lead, I think you should take the lead on that.
7ab47c5
to
2f50a0a
Compare
2f50a0a
to
e22e682
Compare
This commit ensures that every test case relying on the `RUSTUP_AUTO_INSTALL` config option is explicitly setting it, and every other test case will pass regardless of its value.
e22e682
to
2e5dd94
Compare
Closes #4445.