rustup icon indicating copy to clipboard operation
rustup copied to clipboard

toolchain pin puts installed targets under components

Open Kaileshwar16 opened this issue 2 weeks ago • 2 comments

rustup toolchain pin writes installed targets as components in the generated rust-toolchain.toml

to reproduce, run these in a directory without an existing toolchain file or override:

rustup target add wasm32-unknown-unknown
rustup toolchain pin

should'nt the generated file contain targets = ["wasm32-unknown-unknown"] instead of components = ["rust-std-wasm32-unknown-unknown"]?

on a fresh installation, this fails with:

component 'rust-std-wasm32-unknown-unknown' for target 'x86_64-unknown-linux-gnu' is unavailable

It also causes rustup to sync the toolchain on every invocation, which breaks offline builds.

moving the entry to targets fixes both issues.

ran with Rust 1.91.1 on Linux. (main branch)

Kaileshwar16 avatar Nov 22 '26 05:11 Kaileshwar16

@Kaileshwar16 Thanks for the issue! I'll take a look next week.

@rustbot claim

rami3l avatar Nov 22 '26 09:11 rami3l

A note for myself: I think this goes both ways.

On the one hand, "targets" are really just shorthand for components. rustup component add rust-std-wasm32-unknown-unknown works today, so the above rust-toolchain.toml should not be an error:

> rustup component add rust-std-wasm32-unknown-unknown
info: downloading component rust-std
rust-std-wasm32-unknown-unknown installed                       21.95 MiB   

(The above info: downloading component rust-std may be misleading since we are not using the correct display format, may need to be fixed separately.)

should'nt the generated file contain targets = ["wasm32-unknown-unknown"] instead of components = ["rust-std-wasm32-unknown-unknown"]?

On the other hand, ideally this should be the case, but conceptually it should be a purely cosmetic change.

rami3l avatar Nov 22 '26 09:11 rami3l