Verification
Problem
In 2020Q4 support for installing a toolchain defined in rust-toolchain.toml with a new profile key was added to rustup: #2586
While this works, when the profile key is not set, there is no fallback to the global profile setting for rustup. Thus if rust-toolchain.toml exists, despite rustup being configured for a minimal profile, the toolchain will be downloaded with the default profile bringing in over 600MB of HTML docs and additional components.
This took a while to trackdown/confirm why the rustup profile wasn't being respected 😅 While a little surprising, I tried searching for any existing issues and came up empty.
Steps
- Install rustup and set the profile to
minimal.
- Add a
rust-toolchain.toml file in an empty directory, with contents:
[toolchain]
channel = "1.70" # should be a toolchain version that is not installed
- Run
cargo --version, rustup will download the toolchain.
- Check the toolchain install, and notice that there is over 600MB of docs installed despite the
minimal profile:
$ du --bytes -sh ~/.rustup/toolchains/1.77-x86_64-unknown-linux-gnu/share/doc/rust/html
587M /root/.rustup/toolchains/1.77-x86_64-unknown-linux-gnu/share/doc/rust/html
If you repeat these steps but add profile = "minimal" to the rust-toolchain.toml file with a different toolchain version, the HTML docs won't be present, the share/ directory itself will now be about 500KB.
Possible Solution(s)
- If
profile is not defined, use the rustup configured profile setting to align with installing a toolchain via rustup explicitly.
- Document that a
rust-toolchain.toml without a profile key will not fallback to the global rustup profile, which can result in excessive disk usage.
Notes
Past issues requesting the feature support prior to the 2020 PR:
Discussion regarding interoperability across config layers, including better documenting precedence:
Rustup version
$ rustup --version
rustup 1.27.0 (bbb9276d2 2024-03-08)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.75.0 (82e1608df 2023-12-21)`
Installed toolchains
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /root/.rustup
installed toolchains
--------------------
1.75-x86_64-unknown-linux-gnu (default)
1.76-x86_64-unknown-linux-gnu
1.77-x86_64-unknown-linux-gnu
1.78-x86_64-unknown-linux-gnu
active toolchain
----------------
1.75-x86_64-unknown-linux-gnu (default)
rustc 1.75.0 (82e1608df 2023-12-21)
OS version
Windows 11 with WSL2, running rustup via a Docker container (Ubuntu 24.04):
$ cat /etc/os-release | grep PRETTY_NAME
PRETTY_NAME="Ubuntu 24.04 LTS"
$ uname -a
Linux 3d586f91b6a2 5.15.123.1-microsoft-standard-WSL2 #1 SMP Mon Aug 7 19:01:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Verification
Problem
In 2020Q4 support for installing a toolchain defined in
rust-toolchain.tomlwith a new profile key was added to rustup: #2586While this works, when the
profilekey is not set, there is no fallback to the global profile setting for rustup. Thus ifrust-toolchain.tomlexists, despite rustup being configured for aminimalprofile, the toolchain will be downloaded with thedefaultprofile bringing in over 600MB of HTML docs and additional components.This took a while to trackdown/confirm why the rustup profile wasn't being respected 😅 While a little surprising, I tried searching for any existing issues and came up empty.
Steps
minimal.rust-toolchain.tomlfile in an empty directory, with contents:cargo --version, rustup will download the toolchain.minimalprofile:If you repeat these steps but add
profile = "minimal"to therust-toolchain.tomlfile with a different toolchain version, the HTML docs won't be present, theshare/directory itself will now be about 500KB.Possible Solution(s)
profileis not defined, use the rustup configured profile setting to align with installing a toolchain viarustupexplicitly.rust-toolchain.tomlwithout aprofilekey will not fallback to the global rustup profile, which can result in excessive disk usage.Notes
Past issues requesting the feature support prior to the 2020 PR:
--profile minimal#2579Discussion regarding interoperability across config layers, including better documenting precedence:
rust-toolchain.tomland other override sources for components and targets #3483Rustup version
Installed toolchains
OS version