How to use rust-toolchain to pin rust versions in a workspace?

In a workspace, I have and do the following:

$ cat rust-toolchain
[toolchain]
channel = "nightly-2021-01-24"
components = [ "rustfmt", "rust-std", "clippy" ]
targets = [ "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]

$ cargo fmt
error: invalid channel name '[toolchain]' in '.../rust-toolchain'
error: caused by: invalid toolchain name: '[toolchain]'

I'm not sure what I missed.

The TOML format for rust-toolchain was added in a recent version of rustup. Try this command to make sure you have the latest version:

rustup self update
1 Like

Thanks, that was the issue - I just reverted to using the simpler format for now due to being on Nix where running rustup self update is either not possible or not easy.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.