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

Tell user if override is set in the environment after rustup default #1655

Merged
merged 2 commits into from
Mar 6, 2019
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
9 changes: 9 additions & 0 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,15 @@ fn default_(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
println!();
common::show_channel_update(cfg, toolchain.name(), Ok(status))?;
}

let cwd = utils::current_dir()?;
if let Some((toolchain, reason)) = cfg.find_override(&cwd)? {
info!(
"note that the toolchain '{}' is currently in use ({})",
toolchain.name(),
reason
);
}
} else {
let installed_toolchains = cfg.list_toolchains()?;
if installed_toolchains.len() > 0 {
Expand Down
18 changes: 18 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,24 @@ info: default toolchain set to 'nightly-{0}'
});
}

#[test]
fn default_override() {
setup(&|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "override", "set", "nightly"]);
expect_stderr_ok(
config,
&["rustup", "default", "stable"],
for_host!(
r"info: using existing install for 'stable-{0}'
info: default toolchain set to 'stable-{0}'
info: note that the toolchain 'nightly-{0}' is currently in use (directory override for"
),
);
});
}

#[test]
fn rustup_xz() {
setup(&|config| {
Expand Down