Tags: #rust #rustlang #environment #overrides #toolchain
The default toolchain in rust is “stable”.
A user can execute rustup override set <toolchain> to change the default toolchain (e.g. to “nightly” or a specific toolchain version installed using rustup toolchain install <toolchain>), and this will be reflected when running either rustup show active-toolchain or rustc --version (i.e. either of those latter commands will show the version set to be the same as the specified override). The rustup override set command also takes priority over anything set within a rust-toolchain file:
[toolchain]
channel = "stable" # << this would be overridden by `rustup override set <toolchain>`
targets = [ "wasm32-wasi" ]
NOTE: The behaviour triggered by
rustup default <toolchain>is also reflected in the output ofrustup show active-toolchainandrustc --version, but (unlikerustup override set) the behaviour concedes to whatever is defined inside therust-toolchainfile.
Additionally the cargo build command can accept a +<toolchain> indicator (e.g. cargo +1.54.0 build) and that can override any of the prior behaviours I’ve covered.
Here are some useful commands for understanding the rust environment:
rustup show (combines a bunch of the below data into a ‘summary’ view)rustup defaultrustup show active-toolchainrustup override listrustup toolchain listrustup target list --installed --toolchain <toolchain>rustup target add <target> --toolchain <toolchain>rustup update <toolchain> (e.g. update what ‘stable’ refers to †)rustc --print sysrootls -la $(rustc --print sysroot)/lib/rustlib (check for installed targets like wasm32-wasi)† Which is different to any specific toolchain that has been manually installed (using
rustup toolchain install <toolchain>) and then set to be the default usingrustup default <toolchain>.
Refer to https://rust-lang.github.io/rustup/concepts/toolchains.html for more information on the toolchain specification.