From d93c1c83994ae6046a3d9fc0b8f88aed99bacab9 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 23 Sep 2017 02:21:24 +0300 Subject: [PATCH] Support `rustup-init --default-toolchain none` --- README.md | 1 + rustup-init.sh | 1 + src/rustup-cli/self_update.rs | 7 +++++-- tests/cli-inst-interactive.rs | 10 ++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b46a27c3b3..90ea7b55d5 100644 --- a/README.md +++ b/README.md @@ -570,6 +570,7 @@ the shell script. Some examples: $ curl https://sh.rustup.rs -sSf | sh -s -- --help $ curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path $ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly +$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none ``` If you prefer you can directly download `rustup-init` for the diff --git a/rustup-init.sh b/rustup-init.sh index 95b8735ddc..7e089a1fb4 100755 --- a/rustup-init.sh +++ b/rustup-init.sh @@ -36,6 +36,7 @@ FLAGS: OPTIONS: --default-host Choose a default host triple --default-toolchain Choose a default toolchain to install + --default-toolchain none Do not install any toolchains EOF } diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs index 2408a10b74..70f48df03c 100644 --- a/src/rustup-cli/self_update.rs +++ b/src/rustup-cli/self_update.rs @@ -587,7 +587,7 @@ fn customize_install(mut opts: InstallOpts) -> Result { &opts.default_host_triple)); opts.default_toolchain = try!(common::question_str( - "Default toolchain? (stable/beta/nightly)", + "Default toolchain? (stable/beta/nightly/none)", &opts.default_toolchain)); opts.no_modify_path = !try!(common::question_bool( @@ -660,7 +660,10 @@ fn maybe_install_rust(toolchain_str: &str, default_host_triple: &str, verbose: b // a toolchain the user actually wants. Don't do anything. FIXME: // This logic should be part of InstallOpts so that it isn't // possible to select a toolchain then have it not be installed. - if try!(cfg.find_default()).is_none() { + if toolchain_str == "none" { + info!("skipping toolchain installation"); + println!(""); + } else if try!(cfg.find_default()).is_none() { // Set host triple first as it will affect resolution of toolchain_str try!(cfg.set_default_host_triple(default_host_triple)); let toolchain = try!(cfg.get_toolchain(toolchain_str, false)); diff --git a/tests/cli-inst-interactive.rs b/tests/cli-inst-interactive.rs index cb1fe054a9..de1a132fc3 100644 --- a/tests/cli-inst-interactive.rs +++ b/tests/cli-inst-interactive.rs @@ -129,6 +129,16 @@ fn with_no_modify_path() { }); } +#[test] +fn with_no_toolchain() { + setup(&|config| { + let out = run_input(config, &["rustup-init", "--default-toolchain=none"], "\n\n"); + assert!(out.ok); + + expect_stdout_ok(config, &["rustup", "show"], "no active toolchain"); + }); +} + #[test] fn with_non_default_toolchain() { setup(&|config| {