fix(cli/rustup_mode)!: skip auto-installation in some rustup commands#4840
fix(cli/rustup_mode)!: skip auto-installation in some rustup commands#4840rami3l merged 8 commits intorust-lang:mainfrom
rustup commands#4840Conversation
4892599 to
8ab1b84
Compare
|
@djc Commands that should respect auto-installation:
rustup-init No, because the notion of toolchain doesn't exist yet in that stage
install No, because `rustup install` installs the active toolchain by default
uninstall No, similarly to `rustup install`
toolchain No
default No, because `rustup default foo` installs `foo`
show No, because it's query-only
update No, similarly to `rustup toolchain`
check No, because it's query-only
target No, because it operates on an installed toolchain
component No, similarly to `rustup target`
override No
run Yes, because the said toolchain is invoked
which No, because it's query-only
doc Yes, because the said toolchain is relied upon
man Yes, similarly to `rustup doc`
self No, similarly to `rustup-init`
set No
completions NoWhat do you think? |
|
I like it! Should we review |
@djc We have four subcommands here: |
|
Sounds good. Are there other commands with subcommands? |
@djc I wrote all the above analysis with all subcommands in mind already. Please feel free to tell me if you think there are any cases you don't agree with. PS: The best way to enumerate all dispatch points is to go to the code itself: Lines 643 to 770 in 6e68164 |
Okay, just checking! |
d3c1bfb to
320c081
Compare
|
Almost done. The only concern would be that I'll try to fix it here soon... |
|
PS: It's very fun in that I'll just need to search for |
370bf93 to
42b4bea
Compare
|
Oh, the CI passes now, so I'm marking this first PR as ready. Please feel free to let me know if there are any improvements/clarifications to be made :) |
There was a problem hiding this comment.
Pull request overview
This PR addresses rustup auto-install being triggered too eagerly (notably under certain rustup subcommands) by adding a configuration-level switch to disable auto-install earlier during clap dispatch in rustup_mode.
Changes:
- Add
Cfg::allow_auto_installand gateCfg::should_auto_install()on it, so auto-install can be disabled without consulting env/settings. - Decide
allow_auto_installperRustupSubcmdinrustup_mode(enabling it only for subcommands that execute/rely on the active toolchain). - Adjust
rustup show/--versionbehavior and update CLI test snapshots accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/suite/cli_v2.rs | Updates auto-install disable tests to exercise proxy (cargo +nightly) instead of rustup target. |
| tests/suite/cli_rustup.rs | Updates rustup show expectations when the active toolchain is missing. |
| tests/suite/cli_misc.rs | Updates snapshots for version message and which behavior when toolchains are missing. |
| src/config.rs | Introduces allow_auto_install and makes should_auto_install() return false when disallowed. |
| src/cli/setup_mode.rs | Updates Cfg::from_env call to pass allow_auto_install for setup/init flow. |
| src/cli/self_update.rs | Updates test to match new Cfg::from_env signature. |
| src/cli/rustup_mode.rs | Computes allow_auto_install from the selected subcommand; adjusts show and version output behavior. |
| src/cli/proxy_mode.rs | Updates Cfg::from_env call to pass allow_auto_install for proxy execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
42b4bea to
a459730
Compare
a459730 to
326e48d
Compare
326e48d to
d25e8ec
Compare
This comment has been minimized.
This comment has been minimized.
d25e8ec to
cf88faf
Compare
This comment was marked as outdated.
This comment was marked as outdated.
cf88faf to
c037408
Compare
Closes #4836 by making it possible to skip
should_auto_install's dynamic detection entirely.Whether the skip should be applied can be predetermined during
clapdispatch (at least forrustup_mode.rs), so the only remaining question seems to be where we would want to apply the skip.