@@ -3,22 +3,17 @@ title: Installation
3
3
---
4
4
5
5
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.
16
11
17
12
### Unix-Based Operating Systems
18
13
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
20
15
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.
22
17
23
18
#### macOS
24
19
@@ -30,7 +25,7 @@ Open the Terminal application and execute the following commands:
30
25
31
26
# Make sure Homebrew is up-to-date and install some dependencies
32
27
brew update
33
- brew install openssl cmake llvm
28
+ brew install openssl cmake
34
29
```
35
30
36
31
#### Ubuntu/Debian
@@ -59,13 +54,14 @@ Please refer to the separate [guide for Windows users](windows-users.md).
59
54
60
55
## Rust Developer Environment
61
56
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
63
58
configure ` rustup ` :
64
59
65
60
``` bash
66
61
# Install
67
62
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.
69
65
source ~ /.cargo/env
70
66
```
71
67
@@ -79,62 +75,75 @@ rustup default stable
79
75
80
76
Substrate uses [ WebAssembly] ( https://webassembly.org/ ) (Wasm) to produce portable blockchain
81
77
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.
84
80
85
81
#### Rust Nightly Toolchain
86
82
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:
90
88
91
89
``` bash
92
90
rustup install nightly-< yyyy-MM-dd>
93
91
```
94
92
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
+
95
105
#### Wasm Toolchain
96
106
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:
98
108
99
109
``` bash
100
110
rustup target add wasm32-unknown-unknown --toolchain nightly-< yyyy-MM-dd>
101
111
```
102
112
103
113
#### Specifying Nightly Version
104
114
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:
108
119
109
120
``` bash
110
- cargo + nightly-< yyyy-MM-dd> ...
121
+ WASM_BUILD_TOOLCHAIN= nightly-< yyyy-MM-dd> cargo build
111
122
```
112
123
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
+
113
127
#### Latest Nightly
114
128
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 :
117
131
118
132
``` bash
119
- rustup update
120
- rustup update nightly
133
+ rustup install nightly
121
134
rustup target add wasm32-unknown-unknown --toolchain nightly
122
135
```
123
136
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:
131
139
132
140
``` 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
136
142
```
137
143
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
+
138
147
## Test Your Set-Up
139
148
140
149
The best way to ensure that you have successfully prepared a computer for Substrate development is
0 commit comments