Skip to content

Commit c0ee150

Browse files
committed
Auto merge of #1257 - petrochenkov:master, r=alexcrichton
Support `rustup-init --default-toolchain none` To address this use case #309 (comment). This is especially useful when user directories have quotas into which large components (e.g. docs) do not fit.
2 parents 533f098 + d93c1c8 commit c0ee150

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ the shell script. Some examples:
570570
$ curl https://sh.rustup.rs -sSf | sh -s -- --help
571571
$ curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path
572572
$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
573+
$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none
573574
```
574575

575576
If you prefer you can directly download `rustup-init` for the

rustup-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ FLAGS:
3636
OPTIONS:
3737
--default-host <default-host> Choose a default host triple
3838
--default-toolchain <default-toolchain> Choose a default toolchain to install
39+
--default-toolchain none Do not install any toolchains
3940
EOF
4041
}
4142

src/rustup-cli/self_update.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ fn customize_install(mut opts: InstallOpts) -> Result<InstallOpts> {
587587
&opts.default_host_triple));
588588

589589
opts.default_toolchain = try!(common::question_str(
590-
"Default toolchain? (stable/beta/nightly)",
590+
"Default toolchain? (stable/beta/nightly/none)",
591591
&opts.default_toolchain));
592592

593593
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
660660
// a toolchain the user actually wants. Don't do anything. FIXME:
661661
// This logic should be part of InstallOpts so that it isn't
662662
// possible to select a toolchain then have it not be installed.
663-
if try!(cfg.find_default()).is_none() {
663+
if toolchain_str == "none" {
664+
info!("skipping toolchain installation");
665+
println!("");
666+
} else if try!(cfg.find_default()).is_none() {
664667
// Set host triple first as it will affect resolution of toolchain_str
665668
try!(cfg.set_default_host_triple(default_host_triple));
666669
let toolchain = try!(cfg.get_toolchain(toolchain_str, false));

tests/cli-inst-interactive.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ fn with_no_modify_path() {
129129
});
130130
}
131131

132+
#[test]
133+
fn with_no_toolchain() {
134+
setup(&|config| {
135+
let out = run_input(config, &["rustup-init", "--default-toolchain=none"], "\n\n");
136+
assert!(out.ok);
137+
138+
expect_stdout_ok(config, &["rustup", "show"], "no active toolchain");
139+
});
140+
}
141+
132142
#[test]
133143
fn with_non_default_toolchain() {
134144
setup(&|config| {

0 commit comments

Comments
 (0)