Skip to content

Commit 8797fa8

Browse files
committed
address comments
1 parent 31fd3c6 commit 8797fa8

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

doc/src/basics.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ info: downloading self-updates
3030

3131
## Keeping `rustup` up to date
3232

33-
If your `rustup` build with the `no-self-update` feature, it will not be able to update itself.
33+
If your `rustup` was build with the `no-self-update` feature, it will not be able to update itself.
34+
`rustup` does not use this feature by default, including the rustups you downloaded from https://rustup.rs.
3435

35-
If your `rustup` build without the `no-self-update` feature,
36+
If your `rustup` was build without the `no-self-update` feature,
3637
it is possible to control Rustup's automatic self update mechanism with the `auto-self-update` configuration variable.
3738
This setting supports three values: `enable` and `disable` and `check-only`.
3839

3940
* `disable` will ensure that no automatic self updating actions are taken.
40-
* `enable` will mean that `rustup update` and similar commands will also check-for, and install, any update to Rustup.
41+
* `enable` will mean that `rustup update` and similar commands will also check for, and install, any update to Rustup.
4142
* `check-only` will cause any automatic self update to check and report on any updates, but not to automatically install them.
4243

4344
Whether `auto-self-update` is `enable` or not, you can request that Rustup check for, and update itself to the
@@ -50,7 +51,7 @@ info: checking for self-updates
5051
info: downloading self-updates
5152
```
5253

53-
> ### Disable automatic self-updates with the parameter of the command
54+
### Disable automatic self-updates with the parameter of the command
5455
> Since the default value of auto-self-update is `enable`, `rustup` will automatically update itself at the end of any
5556
> toolchain installation as well. You can prevent this automatic behaviour by
5657
> passing the `--no-self-update` argument when running `rustup update` or

src/cli/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use thiserror::Error as ThisError;
1313
pub enum CLIError {
1414
#[error("couldn't determine self executable name")]
1515
NoExeName,
16+
#[error("couldn't determine self executable file path")]
17+
NoExeFilePath,
1618
#[error("rustup is not installed at '{}'", .p.display())]
1719
NotSelfInstalled { p: PathBuf },
1820
#[error("failure reading directory {}", .p.display())]

src/cli/rustup_mode.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use super::{
1717
common,
1818
self_update::{check_rustup_update, SelfUpdateMode},
1919
};
20+
use crate::cli::errors::CLIError;
2021
use crate::dist::dist::{
2122
PartialTargetTriple, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc,
2223
};
@@ -1587,7 +1588,10 @@ fn set_profile(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
15871588

15881589
fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
15891590
if self_update::NEVER_SELF_UPDATE {
1590-
warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",cfg.rustup_dir.display());
1591+
let mut args = crate::process().args_os();
1592+
let arg0 = args.next().map(PathBuf::from);
1593+
let arg0 = arg0.as_ref().and_then(|a| a.to_str());
1594+
warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",arg0.ok_or(CLIError::NoExeFilePath)?);
15911595
}
15921596
cfg.set_auto_self_update(&m.value_of("auto-self-update-mode").unwrap())?;
15931597
Ok(utils::ExitCode(0))

src/cli/self_update.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ impl FromStr for SelfUpdateMode {
125125

126126
impl ToString for SelfUpdateMode {
127127
fn to_string(&self) -> String {
128-
let modes = Self::modes();
129128
match self {
130-
SelfUpdateMode::Enable => modes[0].to_string(),
131-
SelfUpdateMode::Disable => modes[1].to_string(),
132-
SelfUpdateMode::CheckOnly => modes[2].to_string(),
129+
SelfUpdateMode::Enable => "enable",
130+
SelfUpdateMode::Disable => "disable",
131+
SelfUpdateMode::CheckOnly => "check-only",
133132
}
133+
.into()
134134
}
135135
}
136136

src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Default for Settings {
9191
profile: Some("default".to_owned()),
9292
overrides: BTreeMap::new(),
9393
pgp_keys: None,
94-
auto_self_update: Some(SelfUpdateMode::Enable),
94+
auto_self_update: None,
9595
}
9696
}
9797
}

0 commit comments

Comments
 (0)