Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed May 25, 2021
1 parent 31fd3c6 commit 8797fa8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
9 changes: 5 additions & 4 deletions doc/src/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ info: downloading self-updates

## Keeping `rustup` up to date

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

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

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

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

> ### Disable automatic self-updates with the parameter of the command
### Disable automatic self-updates with the parameter of the command
> Since the default value of auto-self-update is `enable`, `rustup` will automatically update itself at the end of any
> toolchain installation as well. You can prevent this automatic behaviour by
> passing the `--no-self-update` argument when running `rustup update` or
Expand Down
2 changes: 2 additions & 0 deletions src/cli/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use thiserror::Error as ThisError;
pub enum CLIError {
#[error("couldn't determine self executable name")]
NoExeName,
#[error("couldn't determine self executable file path")]
NoExeFilePath,
#[error("rustup is not installed at '{}'", .p.display())]
NotSelfInstalled { p: PathBuf },
#[error("failure reading directory {}", .p.display())]
Expand Down
6 changes: 5 additions & 1 deletion src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use super::{
common,
self_update::{check_rustup_update, SelfUpdateMode},
};
use crate::cli::errors::CLIError;
use crate::dist::dist::{
PartialTargetTriple, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc,
};
Expand Down Expand Up @@ -1587,7 +1588,10 @@ fn set_profile(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {

fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
if self_update::NEVER_SELF_UPDATE {
warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",cfg.rustup_dir.display());
let mut args = crate::process().args_os();
let arg0 = args.next().map(PathBuf::from);
let arg0 = arg0.as_ref().and_then(|a| a.to_str());
warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",arg0.ok_or(CLIError::NoExeFilePath)?);
}
cfg.set_auto_self_update(&m.value_of("auto-self-update-mode").unwrap())?;
Ok(utils::ExitCode(0))
Expand Down
8 changes: 4 additions & 4 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ impl FromStr for SelfUpdateMode {

impl ToString for SelfUpdateMode {
fn to_string(&self) -> String {
let modes = Self::modes();
match self {
SelfUpdateMode::Enable => modes[0].to_string(),
SelfUpdateMode::Disable => modes[1].to_string(),
SelfUpdateMode::CheckOnly => modes[2].to_string(),
SelfUpdateMode::Enable => "enable",
SelfUpdateMode::Disable => "disable",
SelfUpdateMode::CheckOnly => "check-only",
}
.into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Default for Settings {
profile: Some("default".to_owned()),
overrides: BTreeMap::new(),
pgp_keys: None,
auto_self_update: Some(SelfUpdateMode::Enable),
auto_self_update: None,
}
}
}
Expand Down

0 comments on commit 8797fa8

Please sign in to comment.