How to switch between Rust toolchains?

The rustup default stable command works well, but the easiest way is to keep a rust-toolchain file inside your project root folder. This is similar to a .nvm file for a NodeJS project.

rust-toolchain

nightly

or

stable

rust-toolchain


Use rustup default <toolchain> to change the default toolchain. You can use the full name (e.g. rustup default stable-x86_64-unknown-linux-gnu) or a short alias (e.g. rustup default stable).

rustup also has methods to override the default in a more scoped manner. See Overrides in the rustup book.