-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(cli/rustup_mode)!: skip auto-installation in some rustup commands
#4840
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
Open
rami3l
wants to merge
8
commits into
rust-lang:main
Choose a base branch
from
rami3l:fix/skip-auto-install
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d53fccf
feat(config): add `Cfg` field to force-disable auto-installation
rami3l bc01f23
fix(cli/setup-mode)!: skip auto-installation in `rustup-init`
rami3l b5484df
refactor(cli/rustup-mode): refine usage of `stdout` term and locks in…
rami3l f20dea6
refactor(cli/rustup-mode): reduce rightward drift in `show()`
rami3l 11d5bde
refactor(cli/rustup-mode): postpone eval of `active_toolchain` in `sh…
rami3l 42a4c2a
refactor(cli/rustup-mode): postpone eval of `active_toolchain_targets…
rami3l 328a182
fix(cli/rustup-mode)!: complete `rustup show` if active toolchain is …
rami3l 326e48d
fix(cli/rustup-mode)!: skip auto-installation in some `rustup` commands
rami3l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,12 +246,19 @@ pub(crate) struct Cfg<'a> { | |
| pub quiet: bool, | ||
| pub current_dir: PathBuf, | ||
| pub process: &'a Process, | ||
|
|
||
| /// If this flag is set to `false`, it can stop `rustup` from automatically installing the | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think best practice for docstrings is to summarize meaning in a way that fits on one line, then expand on that in subsequent lines (usually after an empty line). That makes it a bit easier to skim/skip over them. |
||
| /// active toolchain in certain undesired cases, such as under `rustup component` and `rustup | ||
| /// target` subcommands. This effect has higher precedence than the `RUSTUP_AUTO_INSTALL` | ||
| /// environment variable and the `rustup set auto-install` setting. | ||
| pub allow_auto_install: bool, | ||
| } | ||
|
|
||
| impl<'a> Cfg<'a> { | ||
| pub(crate) fn from_env( | ||
| current_dir: PathBuf, | ||
| quiet: bool, | ||
| allow_auto_install: bool, | ||
| process: &'a Process, | ||
| ) -> Result<Self> { | ||
| // Set up the rustup home directory | ||
|
|
@@ -316,6 +323,7 @@ impl<'a> Cfg<'a> { | |
| quiet, | ||
| current_dir, | ||
| process, | ||
| allow_auto_install, | ||
| }; | ||
|
|
||
| // Run some basic checks against the constructed configuration | ||
|
|
@@ -372,6 +380,10 @@ impl<'a> Cfg<'a> { | |
| } | ||
|
|
||
| pub(crate) fn should_auto_install(&self) -> Result<bool> { | ||
| if !self.allow_auto_install { | ||
| return Ok(false); | ||
| } | ||
|
|
||
| if let Ok(mode) = self.process.var("RUSTUP_AUTO_INSTALL") { | ||
| Ok(mode != "0") | ||
| } else { | ||
|
|
@@ -958,6 +970,7 @@ impl Debug for Cfg<'_> { | |
| dist_root_url, | ||
| quiet, | ||
| current_dir, | ||
| allow_auto_install, | ||
| process: _, | ||
| } = self; | ||
|
|
||
|
|
@@ -975,6 +988,7 @@ impl Debug for Cfg<'_> { | |
| .field("dist_root_url", dist_root_url) | ||
| .field("quiet", quiet) | ||
| .field("current_dir", current_dir) | ||
| .field("allow_auto_install", allow_auto_install) | ||
| .finish() | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it might still be worthwhile here to handle the error cases inside the
matchand yield theOk()case out of thematchto reduce rightward drift a bit more.