Skip to content

Show toolchain paths in rustup show -v output #4270

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 1 commit into from
Mar 30, 2025
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
8 changes: 3 additions & 5 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,6 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
print_header::<Error>(&mut t, "installed toolchains")?;

let default_toolchain_name = cfg.get_default()?;

let last_index = installed_toolchains.len().wrapping_sub(1);
for (n, toolchain_name) in installed_toolchains.into_iter().enumerate() {
let is_default_toolchain = default_toolchain_name.as_ref() == Some(&toolchain_name);
Expand All @@ -1026,11 +1025,10 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
let toolchain = Toolchain::new(cfg, toolchain_name.into())?;
writeln!(
cfg.process.stdout().lock(),
" {}",
toolchain.rustc_version()
" {}\n path: {}",
toolchain.rustc_version(),
toolchain.path().display()
)?;
// To make it easy to see which rustc belongs to which
// toolchain, we separate each pair with an extra newline.
if n != last_index {
writeln!(cfg.process.stdout().lock())?;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,9 +1197,11 @@ installed toolchains
--------------------
nightly-{0} (active, default)
1.3.0 (hash-nightly-2)
path: {2}

nightly-2015-01-01-{0}
1.2.0 (hash-nightly-1)
path: {3}

active toolchain
----------------
Expand All @@ -1214,6 +1216,11 @@ installed targets:
.rustupdir
.join("toolchains")
.join(for_host!("nightly-{0}"))
.display(),
config
.rustupdir
.join("toolchains")
.join(for_host!("nightly-2015-01-01-{0}"))
.display()
),
r"",
Expand Down