1
1
# Overrides
2
2
3
- There are several ways to specify which toolchain ` rustup ` should execute:
4
-
5
- * An explicit toolchain, e.g. ` cargo +beta ` ,
6
- * The ` RUSTUP_TOOLCHAIN ` environment variable,
7
- * A directory override, ala ` rustup override set beta ` ,
8
- * The ` rust-toolchain ` file,
9
- * The default toolchain,
10
-
11
- and they are preferred by ` rustup ` in that order, with the explicit toolchain
12
- having highest precedence, and the default toolchain having the lowest. There
13
- is one exception though: directory overrides and the ` rust-toolchain ` file are
14
- also preferred by their proximity to the current directory. That is, these two
15
- override methods are discovered by walking up the directory tree toward the
16
- filesystem root, and a ` rust-toolchain ` file that is closer to the current
17
- directory will be preferred over a directory override that is further away.
3
+ ` rustup ` automatically determines which [ toolchain] to use when one of the
4
+ installed commands like ` rustc ` is executed. There are several ways to control
5
+ and override which toolchain is used:
6
+
7
+ 1 . A [ toolchain override shorthand] used on the command-line, such as `cargo
8
+ +beta`.
9
+ 2 . The ` RUSTUP_TOOLCHAIN ` environment variable.
10
+ 3 . A [ directory override] , set with the ` rustup override ` command.
11
+ 4 . The [ ` rustup-toolchain ` ] file.
12
+ 5 . The [ default toolchain] .
13
+
14
+ The toolchain is chosen in the order listed above, using the first one that is
15
+ specified. There is one exception though: directory overrides and the
16
+ ` rust-toolchain ` file are also preferred by their proximity to the current
17
+ directory. That is, these two override methods are discovered by walking up
18
+ the directory tree toward the filesystem root, and a ` rust-toolchain ` file
19
+ that is closer to the current directory will be preferred over a directory
20
+ override that is further away.
18
21
19
22
To verify which toolchain is active use ` rustup show ` .
20
23
24
+ [ toolchain ] : concepts/toolchains.md
25
+ [ toolchain override shorthand ] : #toolchain-override-shorthand
26
+ [ directory override ] : #directory-overrides
27
+ [ `rustup-toolchain` ] : #the-toolchain-file
28
+ [ default toolchain ] : #default-toolchain
29
+
21
30
## Toolchain override shorthand
22
31
23
32
The ` rustup ` toolchain proxies can be instructed directly to use a specific
@@ -52,13 +61,17 @@ rustup override set 1.0.0
52
61
To see the active toolchain use ` rustup show ` . To remove the override and use
53
62
the default toolchain again, ` rustup override unset ` .
54
63
64
+ The per-directory overrides are stored in [ a configuration file] in ` rustup ` 's
65
+ home directory.
66
+
67
+ [ a configuration file ] : configuration.md
68
+
55
69
## The toolchain file
56
70
57
- ` rustup ` directory overrides are a local configuration, stored in
58
- ` $RUSTUP_HOME ` . Some projects though find themselves 'pinned' to a specific
59
- release of Rust and want this information reflected in their source
60
- repository. This is most often the case for nightly-only software that pins to
61
- a revision from the release archives.
71
+ Some projects find themselves 'pinned' to a specific release of Rust and want
72
+ this information reflected in their source repository. This is most often the
73
+ case for nightly-only software that pins to a revision from the release
74
+ archives.
62
75
63
76
In these cases the toolchain can be named in the project's directory in a file
64
77
called ` rust-toolchain ` , the content of which is either the name of a single
@@ -83,3 +96,17 @@ toolchains generally, and may only contain the names of the three release
83
96
channels, 'stable', 'beta', 'nightly', Rust version numbers, like '1.0.0', and
84
97
optionally an archive date, like 'nightly-2017-01-01'. They may not name
85
98
custom toolchains, nor host-specific toolchains.
99
+
100
+ ## Default toolchain
101
+
102
+ If no other overrides are set, the global default toolchain will be used. This
103
+ default can be chosen when ` rustup ` is [ installed] . The ` rustup default `
104
+ command can be used to set and query the current default. Run ` rustup default `
105
+ without any arguments to print the current default. Specify a toolchain as an
106
+ argument to change the default:
107
+
108
+ ``` console
109
+ rustup default nightly-2020-07-27
110
+ ```
111
+
112
+ [ installed ] : installation/index.md
0 commit comments