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

Commit 69573cf

Browse files
author
Dan Forbes
authored
Updates to installation guide (#772)
1 parent 9a276c0 commit 69573cf

File tree

10 files changed

+72
-150
lines changed

10 files changed

+72
-150
lines changed

docs/knowledgebase/getting-started/index.md

+51-94
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,42 @@ title: Installation
33
---
44

55
This page will guide you through the steps needed to prepare a computer for Substrate development.
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.
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. Once Rust is configured, you will use its toolchains to interact
9+
with Rust projects; the commands for Rust's toolchains will be the same for all supported,
10+
Unix-based operating systems.
1011

11-
### Unix-Based Operating Systems
12+
## Unix-Based Operating Systems
1213

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

17-
#### macOS
18+
### macOS
1819

1920
Open the Terminal application and execute the following commands:
2021

2122
```bash
2223
# Install Homebrew if necessary https://brew.sh/
2324
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2425

25-
# Make sure Homebrew is up-to-date and install some dependencies
26+
# Make sure Homebrew is up-to-date, install openssl and cmake
2627
brew update
2728
brew install openssl cmake
2829
```
2930

30-
#### Ubuntu/Debian
31+
### Ubuntu/Debian
3132

32-
Use your favorite terminal shell to execute the following commands:
33+
Use a terminal shell to execute the following commands:
3334

3435
```bash
3536
sudo apt update
3637
# May prompt for location information
3738
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl
3839
```
3940

40-
#### Arch Linux
41+
### Arch Linux
4142

4243
Run these commands from a terminal:
4344

@@ -47,7 +48,7 @@ export OPENSSL_LIB_DIR="/usr/lib/openssl-1.0"
4748
export OPENSSL_INCLUDE_DIR="/usr/include/openssl-1.0"
4849
```
4950

50-
### Windows
51+
## Windows
5152

5253
Please refer to the separate [guide for Windows users](windows-users.md).
5354

@@ -59,8 +60,7 @@ configure `rustup`:
5960
```bash
6061
# Install
6162
curl https://sh.rustup.rs -sSf | sh
62-
# Add the rust compiler and other tools to your PATH.
63-
# Make sure to add this to your shell startup script, too.
63+
# Configure
6464
source ~/.cargo/env
6565
```
6666

@@ -74,119 +74,76 @@ rustup default stable
7474

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

8080
#### Rust Nightly Toolchain
8181

82-
Because the nightly toolchain is a moving target and receives daily changes the chance
83-
that some of them break the substrate build from time to time is non-negligible.
84-
85-
Therefore it is advised to use a fixed nightly version rather than the latest one to
86-
build the runtime. You can install a specific version using this command:
82+
Developers building with Substrate should use a specific Rust nightly version that is known to be
83+
compatible with the version of Substrate they are using; this version will vary from project to
84+
project and different projects may use different mechanisms to communicate this version to
85+
developers. For instance, the Polkadot client specifies this information in its
86+
[release notes](https://github.com/paritytech/polkadot/releases). The Substrate Node Template uses
87+
an
88+
[init script](https://github.com/substrate-developer-hub/substrate-node-template/blob/master/scripts/init.sh)
89+
and
90+
[Makefile](https://github.com/substrate-developer-hub/substrate-node-template/blob/master/Makefile)
91+
to specify the Rust nightly version and encapsulate the following steps. Use Rustup to install the
92+
correct nightly:
8793

8894
```bash
8995
rustup install nightly-<yyyy-MM-dd>
9096
```
9197

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

106-
Now, configure the choosen nightly version to work with the Wasm compilation target:
100+
Now, configure the nightly version to work with the Wasm compilation target:
107101

108102
```bash
109103
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
110104
```
111105

112106
#### Specifying Nightly Version
113107

114-
When a Substrate based project builds its included runtime it picks the latest
115-
installed nightly version by default. If the nightly version is incompatible
116-
you can override that decision by setting the `WASM_BUILD_TOOLCHAIN` environment variable
117-
when building the project by using the following command:
108+
Use the `WASM_BUILD_TOOLCHAIN` environment variable to specify the Rust nightly version a Substrate
109+
project should use for Wasm compilation:
118110

119111
```bash
120-
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build
112+
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --release
121113
```
122114

123-
Note that this builds only the runtime with the specified toolchain. The rest of project will
124-
be compiled with your default toolchain, which is usually the latest installed stable toolchain.
115+
Note that this only builds _the runtime_ with the specified nightly. The rest of project will be
116+
compiled with the default toolchain, i.e. the latest installed stable toolchain.
125117

126-
#### Latest Nightly
118+
#### Latest Nightly for Substrate `master`
127119

128-
If you want to build the runtime with the latest nightly compiler which should **generally** be
129-
possible you can install the unspecific `nightly` toolchain:
120+
Developers that are building Substrate _itself_ should always use the latest bug-free versions of
121+
Rust stable and nightly. This is because the Substrate codebase follows the tip of Rust nightly,
122+
which means that changes in Substrate often depend on upstream changes in the Rust nightly compiler.
123+
To ensure your Rust compiler is always up to date, you should run:
130124

131125
```bash
132-
rustup install nightly
126+
rustup update
127+
rustup update nightly
133128
rustup target add wasm32-unknown-unknown --toolchain nightly
134129
```
135130

136-
This toolchain is not tied to a specific version and will be updated just as the
137-
`stable` toolchain:
131+
**It may be necessary to occasionally rerun `rustup update`** if a change in the upstream Substrate
132+
codebase depends on a new feature of the Rust compiler.
138133

139-
```bash
140-
rustup update
141-
```
134+
#### Downgrading Rust Nightly
142135

143-
## Tips
136+
If your computer is configured to use the latest Rust nightly and you would like to downgrade to a
137+
specific nightly version, follow these steps:
144138

145-
**It may be necessary to occasionally rerun `rustup update`** if a change in the upstream Substrate
146-
codebase depends on the most recent version of the Rust compiler.
139+
```sh
140+
rustup uninstall nightly
141+
rustup install nightly-<yyyy-MM-dd>
142+
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
143+
```
147144

148145
## Test Your Set-Up
149146

150147
The best way to ensure that you have successfully prepared a computer for Substrate development is
151148
to follow the steps in our first tutorial,
152149
[Create Your First Substrate Chain](../../tutorials/create-your-first-substrate-chain/).
153-
154-
## Build with Nix shell
155-
156-
Nix is a package manager for many different types of projects, including those based on Rust. Using Nix makes developers confident that the compilation output of their substrate-based projects is reliable and reproducible. Find more benefits on the [Nix website] (https://nixos.org/).
157-
158-
### Steps to use Nix shell
159-
160-
#### Install Nix
161-
162-
Run the following command on a Unix based operating system:
163-
```shell
164-
sh <(curl -L https://nixos.org/nix/install) --daemon
165-
```
166-
167-
#### Verify that Nix was properly installed
168-
169-
```shell
170-
nix-env --version
171-
```
172-
173-
You should see an output like: `nix-env (Nix) 2.3.7`.
174-
175-
#### How to use
176-
177-
If you are using `substrate` or `substrate-node-template`, the `shell.nix` file should already be in the project's root directory.
178-
179-
```shell
180-
cd substrate-node-template # or substrate
181-
182-
nix-shell # start the nix shell environment by using dependencies in file `shell.nix`, it may take some time if this's your first time.
183-
```
184-
185-
#### Run cargo commands in the nix shell
186-
187-
188-
```shell
189-
cargo build --release # build the project
190-
191-
./target/release/node-template # run the compiled binary
192-
```

docs/tutorials/add-a-pallet/import-a-pallet.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ error[E0425]: cannot find function `memory_new` in module `sandbox`
170170
Before moving on, check that the new dependencies resolve correctly by running:
171171

172172
```bash
173-
cargo check -p node-template-runtime
173+
SKIP_WASM_BUILD=1 cargo check -p node-template-runtime
174174
```

docs/tutorials/add-a-pallet/use-a-pallet.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Now you are ready to compile and run your node that has been enhanced with nickn
66
from the Nicks pallet. Compile the node in release mode with:
77

88
```bash
9-
cargo build --release
9+
WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo build --release
1010
```
1111

1212
If the build fails, go back to the previous section and make sure you followed all the steps

docs/tutorials/add-contracts-pallet.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ std = [
168168
Now is a good time to check that everything compiles correctly so far with:
169169

170170
```bash
171-
cargo check
171+
SKIP_WASM_BUILD=1 cargo check
172172
```
173173

174174
## Adding the Contracts Pallet
@@ -286,7 +286,7 @@ should compile, the entire node will not (yet). So we will use this command to c
286286
runtime.
287287

288288
```bash
289-
cargo check -p node-template-runtime
289+
SKIP_WASM_BUILD=1 cargo check -p node-template-runtime
290290
```
291291

292292
### Exposing The Contracts API
@@ -381,7 +381,7 @@ impl_runtime_apis! {
381381
This is another good time to check that your runtime compiles correctly so far.
382382

383383
```bash
384-
cargo check -p node-template-runtime
384+
SKIP_WASM_BUILD=1 cargo check -p node-template-runtime
385385
```
386386

387387
## Updating the Outer Node
@@ -499,7 +499,7 @@ Now you are ready to compile and run your contract-capable node. Compile the nod
499499
with
500500

501501
```bash
502-
cargo build --release
502+
WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo build --release
503503
```
504504

505505
Now launch the executable you just built by running this command

docs/tutorials/build-a-dapp/pallet.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ file, you should be able to recompile your node without warning or error. Run th
300300
root directory of the `substrate-node-template` repository to build and run the node:
301301

302302
```bash
303-
cargo run -- --dev --tmp
303+
WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo run --release -- --dev --tmp
304304
```
305305

306306
Now it is time to interact with our new Proof of Existence pallet!

docs/tutorials/build-permission-network/launch-network.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Launch our permissioned network
55
Before even starting a node, let's make sure everything is compiled for our project.
66

77
```shell
8-
cargo build --release
8+
WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo build --release
99
```
1010

1111
In this part, we'll launch 4 nodes, include 3 well known nodes and 1 normal node. Here are the node keys and peer ids that are used in this tutorial.

docs/tutorials/create-a-pallet.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ You should be able to successfully check the Substrate pallet template with:
8383

8484
```bash
8585
cd test-pallet
86-
cargo check
86+
SKIP_WASM_BUILD=1 cargo check
8787
```
8888

8989
### Your Pallet's `std` Feature
@@ -148,7 +148,7 @@ sp-core = { default-features = false, version = '2.0.0' }
148148
You can confirm that the tests in the Substrate pallet template pass with:
149149

150150
```bash
151-
cargo test
151+
SKIP_WASM_BUILD=1 cargo test
152152
```
153153

154154
When updating this pallet to include your own custom logic, you will likely add dependencies of your
@@ -216,7 +216,7 @@ Make sure you're back in the node template's root directory, then compile the no
216216
development mode with the following command:
217217

218218
```bash
219-
cargo run -- --dev --tmp
219+
WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo run --release -- --dev --tmp
220220
```
221221

222222
Now, start the

docs/tutorials/create-your-first-substrate-chain/setup.md

+7-42
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,11 @@ You will probably need to do some set-up to prepare your computer for Substrate
1414

1515
### Substrate Development
1616

17-
If you are using a Unix-based machine (Linux, MacOS), we have created a simple one-liner to help you
18-
set up your computer:
19-
20-
```bash
21-
curl https://getsubstrate.io -sSf | bash -s -- --fast
22-
```
23-
24-
> If you did not have Rust installed prior to running this script, make sure to restart your
25-
> terminal before continuing.
26-
27-
<details>
28-
<summary>Learn what this script does.</summary>
29-
30-
> You can view the source code for this script by visiting
31-
> [https://getsubstrate.io](https://getsubstrate.io) in your browser.
32-
33-
It will automatically install:
34-
35-
- [CMake](https://cmake.org/install/)
36-
- [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
37-
- [OpenSSL](https://www.openssl.org/)
38-
- [Git](https://git-scm.com/downloads)
39-
- [Rust](https://www.rust-lang.org/tools/install)
40-
41-
</details>
42-
43-
If you are using Windows and do not have the
44-
[Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10), the
45-
process is a bit harder, but well documented
46-
[here](../../knowledgebase/getting-started/windows-users).
17+
Refer to the [official Installation guide](../../knowledgebase/getting-started/). Since this
18+
tutorial uses the Node Template, which includes configuration files and scripts for initializing and
19+
interacting with it, it's not necessary to complete all the steps from the Installation guide. After
20+
`rustup` has been installed and configured, and you've configured the Rust toolchain to default to
21+
the latest stable version you can return to these steps.
4722

4823
## Compiling Substrate
4924

@@ -59,23 +34,13 @@ Template, which serves as a good starting point for building on Substrate.
5934
2. Initialize your WebAssembly build environment
6035

6136
```bash
62-
# Load settings into the current shell script if you can't use rustup command
63-
# If you've run this before, you don't need to run it again. But doing so is harmless.
64-
source ~/.cargo/env
65-
66-
# Update Rust
67-
rustup update nightly
68-
rustup update stable
69-
70-
# Add Wasm target
71-
rustup target add wasm32-unknown-unknown --toolchain nightly
37+
make init
7238
```
7339

7440
3. Compile the Node Template
7541

7642
```bash
77-
cd substrate-node-template/
78-
cargo build --release
43+
make build
7944
```
8045

8146
The time required for the compilation step depends on the hardware you're using. Don't wait before

0 commit comments

Comments
 (0)