Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

Commit bd5bb28

Browse files
authored
Rework how the toolchains are explained (#739)
1 parent 3f3c63e commit bd5bb28

File tree

1 file changed

+48
-39
lines changed
  • docs/knowledgebase/getting-started

1 file changed

+48
-39
lines changed

docs/knowledgebase/getting-started/index.md

+48-39
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ title: Installation
33
---
44

55
This page will guide you through the steps needed to prepare a computer for Substrate development.
6-
Since Substrate is built with [the Rust programming language](https://www.rust-lang.org/), the first
7-
thing you will need to do is prepare the computer for Rust development - these steps will vary based
8-
on the computer's operating system. Then, you can use the helpful utilities from the Rust toolchain
9-
to configure the Rust development environment - these steps will be the same for all the
10-
(Unix-based) operating systems discussed on this page.
11-
12-
## Operating System-Dependent Set-Up
13-
14-
Follow the steps for your computer's operating system before installing and configuring the Rust
15-
toolchain.
6+
As Substrate is built with [the Rust programming language](https://www.rust-lang.org/), the first
7+
thing you will need to do is prepare the development enviroment, these steps will vary based
8+
on the computer's operating system. You can utilize helpful utilities from the Rust toolchain
9+
to configure the Rust development environment. Note that these steps will be the same for all
10+
Unix-based operating systems discussed on this page.
1611

1712
### Unix-Based Operating Systems
1813

19-
Substrate development is easiest on Unix-based operating systems, like macOS or Linux. The examples
14+
Substrate development is optimized for Unix-based operating systems like macOS or Linux. The examples
2015
in the Substrate [Tutorials](../../../../tutorials) and [Recipes](https://substrate.dev/recipes/)
21-
use Unix-style terminals to demonstrate how to interact with Substrate from the command line.
16+
use the terminal to demonstrate how to interact with Substrate from the command line.
2217

2318
#### macOS
2419

@@ -30,7 +25,7 @@ Open the Terminal application and execute the following commands:
3025

3126
# Make sure Homebrew is up-to-date and install some dependencies
3227
brew update
33-
brew install openssl cmake llvm
28+
brew install openssl cmake
3429
```
3530

3631
#### Ubuntu/Debian
@@ -59,13 +54,14 @@ Please refer to the separate [guide for Windows users](windows-users.md).
5954

6055
## Rust Developer Environment
6156

62-
This guide uses [`rustup`](https://rustup.rs/) to help manage the Rust toolchain; first, install and
57+
This guide uses [`rustup`](https://rustup.rs/) to help manage the Rust toolchain. First install and
6358
configure `rustup`:
6459

6560
```bash
6661
# Install
6762
curl https://sh.rustup.rs -sSf | sh
68-
# Configure
63+
# Add the rust compiler and other tools to your PATH.
64+
# Make sure to add this to your shell startup script, too.
6965
source ~/.cargo/env
7066
```
7167

@@ -79,62 +75,75 @@ rustup default stable
7975

8076
Substrate uses [WebAssembly](https://webassembly.org/) (Wasm) to produce portable blockchain
8177
runtimes. You will need to configure your Rust compiler to use
82-
[`nightly` builds](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) to allow you to
83-
compile Rust code to the Wasm target.
78+
[`nightly` builds](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) to allow
79+
compiled substrate compatible runtimes to Wasm.
8480

8581
#### Rust Nightly Toolchain
8682

87-
Developers that are building _with_ Substrate (as opposed to the developers building Substrate
88-
_itself_) should use a specific Rust nightly version that is known to be compatible with the version
89-
of Substrate they are using. Use Rustup to install the correct nightly:
83+
Because the nightly toolchain is a moving target and receives daily changes the chance
84+
that some of them break the substrate build from time to time is non-negligible.
85+
86+
Therefore it is advised to use a fixed nightly version rather than the latest one to
87+
build the runtime. You can install a specific version using this command:
9088

9189
```bash
9290
rustup install nightly-<yyyy-MM-dd>
9391
```
9492

93+
---
94+
**NOTE**
95+
Due to a regression in the rust compiler, using the newest rust nightly for compiling
96+
the runtime will result in compilation errors. Therefore, it is advised to use the
97+
following version until this issue is resolved:
98+
99+
```bash
100+
rustup install nightly-2010-10-06
101+
```
102+
103+
---
104+
95105
#### Wasm Toolchain
96106

97-
Now, configure the nightly version to work with the Wasm compilation target:
107+
Now, configure the choosen nightly version to work with the Wasm compilation target:
98108

99109
```bash
100110
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
101111
```
102112

103113
#### Specifying Nightly Version
104114

105-
If you are working with a Substrate-based project that does not include a toolchain file, you can
106-
use the Rust build and package manager, [Cargo](https://doc.rust-lang.org/cargo/), to specify a
107-
nightly version:
115+
When a Substrate based project builds its included runtime it picks the latest
116+
installed nightly version by default. If the nightly version is incompatible
117+
you can override that decision by setting the `WASM_BUILD_TOOLCHAIN` environment variable
118+
when building the project by using the following command:
108119

109120
```bash
110-
cargo +nightly-<yyyy-MM-dd> ...
121+
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build
111122
```
112123

124+
Note that this builds only the runtime with the specified toolchain. The rest of project will
125+
be compiled with your default toolchain which is usually the latest installed stable toolchain.
126+
113127
#### Latest Nightly
114128

115-
Developers that are building Substrate _itself_ should always uses the latest version of Rust stable
116-
and nightly for compilation. To ensure your Rust compiler is always up to date, you should run:
129+
If you want to build the runtime with the latest nightly compiler which should **generally** be
130+
possible you can install the unspecific `nightly` toolchain:
117131

118132
```bash
119-
rustup update
120-
rustup update nightly
133+
rustup install nightly
121134
rustup target add wasm32-unknown-unknown --toolchain nightly
122135
```
123136

124-
**It may be necessary to occasionally rerun `rustup update`** if a change in the upstream Substrate
125-
codebase depends on a new feature of the Rust compiler.
126-
127-
#### Downgrading Rust Nightly
128-
129-
If your computer is configured to use the latest Rust nightly and you would like to downgrade to a
130-
specific nightly version, follow these steps:
137+
This toolchain is not tied to a specific version and will be updated just as the
138+
`stable` toolchain:
131139

132140
```bash
133-
rustup uninstall nightly
134-
rustup install nightly-<yyyy-MM-dd>
135-
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
141+
rustup update
136142
```
137143

144+
**It may be necessary to occasionally rerun `rustup update`** if a change in the upstream Substrate
145+
codebase depends on the most recent version of the Rust compiler.
146+
138147
## Test Your Set-Up
139148

140149
The best way to ensure that you have successfully prepared a computer for Substrate development is

0 commit comments

Comments
 (0)