Skip to content

rust-toolchain.toml is not used for rustup toolchain install #4216

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

Closed
2 tasks done
Tracked by #4231 ...
nazar-pc opened this issue Mar 4, 2025 · 17 comments
Closed
2 tasks done
Tracked by #4231 ...

rust-toolchain.toml is not used for rustup toolchain install #4216

nazar-pc opened this issue Mar 4, 2025 · 17 comments
Labels
Milestone

Comments

@nazar-pc
Copy link

nazar-pc commented Mar 4, 2025

Verification

Problem

Like many others, I hit an issue where things stopped working in CI because latest version of Rustup didn't install the toolchain implicitly anymore.

I reached out to rustup toolchain install, but looks like it is not exactly equivalent because it didn't install any components mentioned in rust-toolchain.toml:

56.30 error: "/root/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/Cargo.lock" does not exist, unable to build with the standard library, try:
56.30         rustup component add rust-src --toolchain nightly-2024-12-24-x86_64-unknown-linux-gnu

Steps

  1. Have rust-toolchain.toml with components = ["rust-src"]
  2. Run rustup toolchain install

I expect for toolchain to be installed with all components and targets to be installed too.

Right now components and targets do not seem to be installed.

Possible Solution(s)

No response

Notes

It'd be amazing if I could also install rustup itself with --default-toolchain none and simply rely on rustup toolchain install so I don't have to duplicate the version in multiple places of the project.

Rustup version

rustup 1.28.0 (6e19fbec7 2025-03-02)

Installed toolchains

-

OS version

Ubuntu 24.04
@rami3l
Copy link
Member

rami3l commented Mar 8, 2025

@nazar-pc Thanks for your report. However I did consider this case in my implementation and I have even written a test for it:

async fn file_override_toml_format_add_missing_components() {
let mut cx = CliTestContext::new(Scenario::SimpleV2).await;
cx.config.expect_ok(&["rustup", "default", "stable"]).await;
cx.config
.expect_not_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)")
.await;
let cwd = cx.config.current_dir();
let toolchain_file = cwd.join("rust-toolchain");
raw::write_file(
&toolchain_file,
r#"
[toolchain]
components = [ "rust-src" ]
"#,
)
.unwrap();
cx.config
.expect_stderr_ok(
&["rustup", "toolchain", "install"],
"info: installing component 'rust-src'",
)
.await;
cx.config
.expect_stdout_ok(&["rustup", "component", "list"], "rust-src (installed)")
.await;
}

Would you mind sharing more about how this issue can be reproduced?

@rami3l
Copy link
Member

rami3l commented Mar 8, 2025

@nazar-pc Looking at https://github.com/autonomys/subspace/pull/3412/files it seems to me that the problem is not about rustup toolchain install not installing the right components, but rather the active toolchain is somehow not picked up?

Anyway, I've not been able to reproduce this locally. It'd be great if you could provide me with some further hints! 🙇

BTW @Kobzol are you having the same problem on your side?

@Kobzol
Copy link
Contributor

Kobzol commented Mar 8, 2025

I'm not sure what do you mean by "on my side" :)

@rami3l
Copy link
Member

rami3l commented Mar 8, 2025

I'm not sure what do you mean by "on my side" :)

@Kobzol Oh I just saw you hitting +1 on this problem, so I assume you might have relevant experience WRT this issue? Please don't mind me if I got it wrong...

@Kobzol
Copy link
Contributor

Kobzol commented Mar 8, 2025

So we hit some issue after the rustup update with the Rust for Linux CI job, but it was something slightly different (something about the inability to pass arguments to custom/local toolchains). But I since removed rustup from our CI, since I realized it was not needed 😅

@nazar-pc
Copy link
Author

nazar-pc commented Mar 8, 2025

rust-toolchain.toml:

[toolchain]
channel = "nightly-2024-12-24"
components = ["rust-src"]
targets = ["wasm32-unknown-unknown"]
profile = "default"

Then execute:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
~/.cargo/bin/rustup toolchain install

Next try to build with -Z build-std that expects rust-src (mentioned in rust-toolchain.toml).

According to the logs above it was not being installed in 1.28.0.

@rami3l
Copy link
Member

rami3l commented Mar 9, 2025

@nazar-pc I've spun up a new ARM64 Alpine container and I was not able to reproduce this:

> printf '[toolchain]\nchannel = "nightly-2024-12-24"\ncomponents = ["rust-src"]\ntargets = ["wasm32-unknown-unknown"]
\nprofile = "default"' > rust-toolchain.toml
[..]

> apk add curl
[..]

> curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
info: downloading installer
info: profile set to 'default'
info: default host triple is aarch64-unknown-linux-musl
info: skipping toolchain installation


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
source "$HOME/.cargo/env.nu"    # For nushell

> ~/.cargo/bin/rustup toolchain install
info: syncing channel updates for 'nightly-2024-12-24-aarch64-unknown-linux-musl'
info: latest update on 2024-12-24, rust version 1.85.0-nightly (bdc6b3de4 2024-12-23)
info: downloading component 'cargo'
  8.5 MiB /   8.5 MiB (100 %)   1.3 MiB/s in  2s         
info: downloading component 'clippy'
  3.0 MiB /   3.0 MiB (100 %) 956.6 KiB/s in  4s         
info: downloading component 'rust-docs'
 16.7 MiB /  16.7 MiB (100 %)   3.6 MiB/s in  5s         
info: downloading component 'rust-src'
info: downloading component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)   4.1 MiB/s in  7s         
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
 19.3 MiB /  19.3 MiB (100 %)   4.8 MiB/s in  6s         
info: downloading component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)   4.1 MiB/s in 23s         
info: downloading component 'rustfmt'
  2.4 MiB /   2.4 MiB (100 %)   1.2 MiB/s in  2s         
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 16.7 MiB /  16.7 MiB (100 %)  11.0 MiB/s in  1s         
info: installing component 'rust-src'
info: installing component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)  19.2 MiB/s in  1s         
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
 19.3 MiB /  19.3 MiB (100 %)  19.3 MiB/s in  1s         
info: installing component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)  19.5 MiB/s in  4s         
info: installing component 'rustfmt'
info: the active toolchain `nightly-2024-12-24-aarch64-unknown-linux-musl` has been installed
info: it's active because: overridden by '/rust-toolchain.toml'

After all this maneuver, the file that you are asking for is in place:

> ~/.cargo/bin/rustup component list --installed
cargo-aarch64-unknown-linux-musl
clippy-aarch64-unknown-linux-musl
rust-docs-aarch64-unknown-linux-musl
rust-src
rust-std-aarch64-unknown-linux-musl
rust-std-wasm32-unknown-unknown
rustc-aarch64-unknown-linux-musl
rustfmt-aarch64-unknown-linux-musl

> ls -lah ~/.rustup/toolchains/nightly-2024-12-24-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/
total 96K    
drwxr-xr-x   20 root     root        4.0K Mar  9 01:06 .
drwxr-xr-x    4 root     root        4.0K Mar  9 01:06 ..
-rw-r--r--    1 root     root       11.2K Mar  9 01:06 Cargo.lock
-rw-r--r--    1 root     root        1.6K Mar  9 01:06 Cargo.toml
drwxr-xr-x    5 root     root        4.0K Mar  9 01:06 alloc
drwxr-xr-x    8 root     root        4.0K Mar  9 01:06 backtrace
drwxr-xr-x    5 root     root        4.0K Mar  9 01:06 core
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 panic_abort
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 panic_unwind
drwxr-xr-x    4 root     root        4.0K Mar  9 01:06 portable-simd
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 proc_macro
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 profiler_builtins
drwxr-xr-x    2 root     root        4.0K Mar  9 01:06 rtstartup
drwxr-xr-x    2 root     root        4.0K Mar  9 01:06 rustc-std-workspace-alloc
drwxr-xr-x    2 root     root        4.0K Mar  9 01:06 rustc-std-workspace-core
drwxr-xr-x    2 root     root        4.0K Mar  9 01:06 rustc-std-workspace-std
drwxr-xr-x    5 root     root        4.0K Mar  9 01:06 std
drwxr-xr-x    7 root     root        4.0K Mar  9 01:06 stdarch
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 sysroot
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 test
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 unwind
drwxr-xr-x    3 root     root        4.0K Mar  9 01:06 windows_targets

@nazar-pc
Copy link
Author

nazar-pc commented Mar 9, 2025

Well, that was not the behavior as of 1.28.0, maybe you need RUSTUP_AUTO_INSTALL=0 to reproduce it now?

@rami3l
Copy link
Member

rami3l commented Mar 9, 2025

Well, that was not the behavior as of 1.28.0, maybe you need RUSTUP_AUTO_INSTALL=0 to reproduce it now?

@nazar-pc I wrote that logic and I believe there hasn't been that much of a logic change in terms of active toolchain detection, only installation.

But anyway below is a retry with RUSTUP_AUTO_INSTALL=0:

> ~/.cargo/bin/rustup toolchain uninstall nightly-2024-12-24
warn: removing the active toolchain; a toolchain override will be required for running Rust tools
info: uninstalling toolchain 'nightly-2024-12-24-aarch64-unknown-linux-musl'
info: toolchain 'nightly-2024-12-24-aarch64-unknown-linux-musl' uninstalled

> RUSTUP_AUTO_INSTALL=0 ~/.cargo/bin/rustup toolchain install
info: syncing channel updates for 'nightly-2024-12-24-aarch64-unknown-linux-musl'
info: latest update on 2024-12-24, rust version 1.85.0-nightly (bdc6b3de4 2024-12-23)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-src'
info: downloading component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)  18.4 MiB/s in  1s         
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
 19.3 MiB /  19.3 MiB (100 %)  17.9 MiB/s in  1s         
info: downloading component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)  13.4 MiB/s in  6s         
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 16.7 MiB /  16.7 MiB (100 %)  12.8 MiB/s in  1s         
info: installing component 'rust-src'
info: installing component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)  19.7 MiB/s in  1s         
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
info: installing component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)  20.4 MiB/s in  4s         
info: installing component 'rustfmt'
info: the active toolchain `nightly-2024-12-24-aarch64-unknown-linux-musl` has been installed
info: it's active because: overridden by '/rust-toolchain.toml'

> ls -lah ~/.rustup/toolchains/nightly-2024-12-24-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/
total 96K    
drwxr-xr-x   20 root     root        4.0K Mar  9 01:16 .
drwxr-xr-x    4 root     root        4.0K Mar  9 01:16 ..
-rw-r--r--    1 root     root       11.2K Mar  9 01:16 Cargo.lock
-rw-r--r--    1 root     root        1.6K Mar  9 01:16 Cargo.toml
drwxr-xr-x    5 root     root        4.0K Mar  9 01:16 alloc
drwxr-xr-x    8 root     root        4.0K Mar  9 01:16 backtrace
drwxr-xr-x    5 root     root        4.0K Mar  9 01:16 core
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 panic_abort
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 panic_unwind
drwxr-xr-x    4 root     root        4.0K Mar  9 01:16 portable-simd
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 proc_macro
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 profiler_builtins
drwxr-xr-x    2 root     root        4.0K Mar  9 01:16 rtstartup
drwxr-xr-x    2 root     root        4.0K Mar  9 01:16 rustc-std-workspace-alloc
drwxr-xr-x    2 root     root        4.0K Mar  9 01:16 rustc-std-workspace-core
drwxr-xr-x    2 root     root        4.0K Mar  9 01:16 rustc-std-workspace-std
drwxr-xr-x    5 root     root        4.0K Mar  9 01:16 std
drwxr-xr-x    7 root     root        4.0K Mar  9 01:16 stdarch
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 sysroot
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 test
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 unwind
drwxr-xr-x    3 root     root        4.0K Mar  9 01:16 windows_targets

@nazar-pc
Copy link
Author

nazar-pc commented Mar 9, 2025

I wish there was an easy way to retry 1.28.0 specifically. But if it is no longer an issue - great!

@rami3l
Copy link
Member

rami3l commented Mar 9, 2025

I wish there was an easy way to retry 1.28.0 specifically. But if it is no longer an issue - great!

@nazar-pc I cannot reproduce this with 1.28.0 either:

> ~/.cargo/bin/rustup self uninstall
[..]
Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
$HOME/.cargo/bin from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
info: removing cargo home
info: removing rustup binaries
info: rustup is uninstalled

> curl -sSf https://static.rust-lang.org/rustup/archive/1.28.0/aarch64-unknown-linux-musl/rustup-init > rustup-init && chmod +x ./rustup-init
[..]

> ./rustup-init -y --default-toolchain none
info: profile set to 'default'
info: default host triple is aarch64-unknown-linux-musl
info: skipping toolchain installation


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
source "$HOME/.cargo/env.nu"    # For nushell

> ~/.cargo/bin/rustup --version
rustup 1.28.0 (6e19fbec7 2025-03-02)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `(error reading rustc version)`

> ~/.cargo/bin/rustup toolchain install
info: syncing channel updates for 'nightly-2024-12-24-aarch64-unknown-linux-musl'
info: latest update on 2024-12-24, rust version 1.85.0-nightly (bdc6b3de4 2024-12-23)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 16.7 MiB /  16.7 MiB (100 %)  16.0 MiB/s in  1s         
info: downloading component 'rust-src'
info: downloading component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)  12.2 MiB/s in  2s         
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
 19.3 MiB /  19.3 MiB (100 %)  12.6 MiB/s in  1s         
info: downloading component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)  12.5 MiB/s in  7s         
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 16.7 MiB /  16.7 MiB (100 %)  11.5 MiB/s in  1s         
info: installing component 'rust-src'
info: installing component 'rust-std'
 26.7 MiB /  26.7 MiB (100 %)  19.2 MiB/s in  1s         
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
info: installing component 'rustc'
 85.2 MiB /  85.2 MiB (100 %)  20.0 MiB/s in  4s         
info: installing component 'rustfmt'
info: the active toolchain `nightly-2024-12-24-aarch64-unknown-linux-musl` has been installed
info: it's active because: overridden by '/rust-toolchain.toml'

... and here we are again:

> ls -lah ~/.rustup/toolchains/nightly-2024-12-24-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/
total 96K    
drwxr-xr-x   20 root     root        4.0K Mar  9 01:28 .
drwxr-xr-x    4 root     root        4.0K Mar  9 01:28 ..
-rw-r--r--    1 root     root       11.2K Mar  9 01:28 Cargo.lock
-rw-r--r--    1 root     root        1.6K Mar  9 01:28 Cargo.toml
drwxr-xr-x    5 root     root        4.0K Mar  9 01:28 alloc
drwxr-xr-x    8 root     root        4.0K Mar  9 01:28 backtrace
drwxr-xr-x    5 root     root        4.0K Mar  9 01:28 core
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 panic_abort
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 panic_unwind
drwxr-xr-x    4 root     root        4.0K Mar  9 01:28 portable-simd
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 proc_macro
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 profiler_builtins
drwxr-xr-x    2 root     root        4.0K Mar  9 01:28 rtstartup
drwxr-xr-x    2 root     root        4.0K Mar  9 01:28 rustc-std-workspace-alloc
drwxr-xr-x    2 root     root        4.0K Mar  9 01:28 rustc-std-workspace-core
drwxr-xr-x    2 root     root        4.0K Mar  9 01:28 rustc-std-workspace-std
drwxr-xr-x    5 root     root        4.0K Mar  9 01:28 std
drwxr-xr-x    7 root     root        4.0K Mar  9 01:28 stdarch
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 sysroot
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 test
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 unwind
drwxr-xr-x    3 root     root        4.0K Mar  9 01:28 windows_targets

@rami3l
Copy link
Member

rami3l commented Mar 9, 2025

@nazar-pc I'm really sorry for your previous bad experience with rustup, but without a proper reproduction I'm afraid we cannot really proceed further with this one. As such, I'll be closing this issue for now.

Please feel free to provide further information if you have encountered similar problems, and I'll be glad to reopen it! 🙇

@rami3l rami3l closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2025
@rami3l
Copy link
Member

rami3l commented Mar 9, 2025

@nazar-pc It occurred to me that it's probably not a rustup issue, but the error message has misled you to us.

cc @weihanglo for its probable cargo relevance.

@weihanglo
Copy link
Member

56.30 error: "/root/.rustup/toolchains/nightly-2024-12-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/Cargo.lock" does not exist, unable to build with the standard library, try:
56.30 rustup component add rust-src --toolchain nightly-2024-12-24-x86_64-unknown-linux-gnu

This error message was certainly emitted from Cargo, though it needs the rust-src (the source code libstd) available to build std. I don't see anything wrong in Cargo here. Need a minimal complete verifiable example.

@Oliboy50
Copy link

ℹ I had the same kind of issue as the opener at the same time (in my case, it was about the clippy component instead of rust-src, but it was also about the rust-toolchain.toml file).

And I confirm, at least in my case, that the error is gone with the release of rustup 1.28.1, thanks for your time.

@rami3l
Copy link
Member

rami3l commented Mar 10, 2025

@Oliboy50 Thanks for sharing your experience, however AFAIK nothing has changed in terms of toolchain installation across v1.28.0 and v1.28.1, so I'm not sure if the problem is really gone. Probably it's just delayed.

@Oliboy50
Copy link

Oliboy50 commented Mar 10, 2025

I don't know... what I can tell is that cargo clippy ... was the first command that I was trying to run... so maybe the error message would have been different using a command that would not need any "extra toolchain component" such as cargo build?

@rami3l rami3l added this to the 1.28.2 milestone Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants