Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch between Rust toolchains?

Tags:

rust

rustup

rustup help toolchain lists the following sub-commands

SUBCOMMANDS:     list         List installed toolchains     install      Install or update a given toolchain     uninstall    Uninstall a toolchain     link         Create a custom toolchain by symlinking to a directory     help         Prints this message or the help of the given subcommand(s) 

I have the following toolchains installed

stable-x86_64-unknown-linux-gnu (default) nightly-2019-09-05-x86_64-unknown-linux-gnu nightly-x86_64-unknown-linux-gnu master 

I was trying to solve an issue for rust-clippy so I had to install the master toolchain. Even though stable is set as my default toolchain, my current toolchain is master and I would like to switch back to stable. How do I do it without uninstalling the master toolchain?

Is there no switch subcommand?

like image 444
Palash Nigam Avatar asked Oct 03 '19 20:10

Palash Nigam


People also ask

What is toolchain in Rust?

A toolchain is a specific version of the collection of programs needed to compile a Rust application. It includes, but is not limited to: The compiler, rustc. The dependency manager and build tool, cargo. The documentation generator, rustdoc.

What is Rustup used for?

Rustup is the official tool used to manage Rust tooling. Not only can it be used to install Rust and keep it updated, it also allows you to seamlessly switch between the stable, beta, and nightly Rust compilers and tooling.

What is nightly version of Rust?

A new feature is added to Rust: a new commit lands on the master branch. Each night, a new nightly version of Rust is produced. Every day is a release day, and these releases are created by our release infrastructure automatically.


2 Answers

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

like image 72
STEEL Avatar answered Oct 01 '22 21:10

STEEL


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.

like image 45
Francis Gagné Avatar answered Oct 01 '22 21:10

Francis Gagné