Skip to content

feat(cli): show the toolchain path with rustup show [active-toolchain] --verbose #4130

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

Merged
merged 3 commits into from
Dec 30, 2024
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
10 changes: 7 additions & 3 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,11 @@ fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
&active_reason,
)?;
writeln!(t.lock(), "name: {}", active_toolchain.name())?;
writeln!(t.lock(), "compiler: {}", active_toolchain.rustc_version())?;
writeln!(t.lock(), "active because: {}", active_reason)?;
if verbose {
writeln!(t.lock(), "compiler: {}", active_toolchain.rustc_version())?;
writeln!(t.lock(), "path: {}", active_toolchain.path().display())?;
}

// show installed targets for the active toolchain
writeln!(t.lock(), "installed targets:")?;
Expand Down Expand Up @@ -1092,8 +1095,9 @@ fn show_active_toolchain(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode
if verbose {
writeln!(
cfg.process.stdout().lock(),
"compiler: {}",
toolchain.rustc_version()
"compiler: {}\npath: {}",
toolchain.rustc_version(),
toolchain.path().display(),
)?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ pub fn this_host_triple() -> String {
// Format a string with this host triple.
#[macro_export]
macro_rules! for_host {
($s: expr) => {
&format!($s, $crate::test::this_host_triple())
($s:tt $($arg:tt)*) => {
&format!($s, $crate::test::this_host_triple() $($arg)*)
};
}

Expand Down
27 changes: 17 additions & 10 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use rustup::test::{
use rustup::utils::raw;

macro_rules! for_host_and_home {
($config:expr, $s: expr) => {
&format!($s, this_host_triple(), $config.rustupdir)
($config:expr, $s:tt $($arg:tt)*) => {
&format!($s, this_host_triple(), $config.rustupdir $($arg)*)
};
}

Expand Down Expand Up @@ -661,7 +661,6 @@ nightly-{0} (active, default)
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (hash-nightly-2)
active because: it's the default toolchain
installed targets:
{0}
Expand Down Expand Up @@ -735,7 +734,6 @@ nightly-{0} (active, default)
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (hash-nightly-2)
active because: it's the default toolchain
installed targets:
{0}
Expand Down Expand Up @@ -774,7 +772,6 @@ nightly-{0} (active, default)
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (xxxx-nightly-2)
active because: it's the default toolchain
installed targets:
{1}
Expand Down Expand Up @@ -831,7 +828,6 @@ nightly-{0} (active, default)
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (xxxx-nightly-2)
active because: it's the default toolchain
installed targets:
{1}
Expand Down Expand Up @@ -1139,7 +1135,6 @@ nightly-{0} (active, default)
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (hash-nightly-2)
active because: overridden by environment variable RUSTUP_TOOLCHAIN
installed targets:
{0}
Expand Down Expand Up @@ -1227,11 +1222,17 @@ nightly-2015-01-01-{0}
active toolchain
----------------
name: nightly-{0}
compiler: 1.3.0 (hash-nightly-2)
active because: it's the default toolchain
compiler: 1.3.0 (hash-nightly-2)
path: {2}
installed targets:
{0}
"
",
config
.rustupdir
.join("toolchains")
.join(for_host!("nightly-{0}"))
.display()
),
r"",
)
Expand All @@ -1249,7 +1250,13 @@ async fn show_active_toolchain_with_verbose() {
r"nightly-{0}
active because: it's the default toolchain
compiler: 1.3.0 (hash-nightly-2)
"
path: {1}
",
cx.config
.rustupdir
.join("toolchains")
.join(for_host!("nightly-{0}"))
.display()
),
r"",
)
Expand Down
Loading