Skip to content
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

Support rustup-init --default-toolchain none #1257

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ FLAGS:
OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
--default-toolchain none Do not install any toolchains
EOF
}

Expand Down
7 changes: 5 additions & 2 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ fn customize_install(mut opts: InstallOpts) -> Result<InstallOpts> {
&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(
Expand Down Expand Up @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions tests/cli-inst-interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down