Issues
Diagnose and fix Rust and Substrate development environment issues.
Last updated
Diagnose and fix Rust and Substrate development environment issues.
Last updated
If compiling the fails, the problem is most likely to be caused by how Rust is configured in your development environment. This section suggests how you can diagnose and fix configuration issues.
To see information about the Rust toolchain that you are currently using, run the following command:
This command displays output similar to the following Ubuntu example:
In this example, the default toolchain is from the stable
release channel for Linux running on x86_64 architecture. The sample output also indicates that the nightly-x86_64-unknown-linux-gnu
toolchain is installed and there are two targets installed:
x86_64-unknown-linux-gnu
the native Rust target for Linux.
wasm32-unknown-unknown
the WebAssembly target.
In general, you should always use the latest versions of Rust stable
and nightly
builds because changes in Substrate often depend on upstream changes in the Rust nightly
compiler build. To ensure your Rust compiler is always up to date, you should run the following commands:
After you identify the specific nightly
toolchain version to use, you can install it in your development environment by running a command similar to the following:
For example:
After you install a specific version of the nightly toolchain, configure the WebAssembly target to use it by running a command similar to the following:
For example:
You can set the WASM_BUILD_TOOLCHAIN
environment variable to specify the version of the nightly
toolchain to use for compiling WebAssembly.For example:
This command builds the runtime using the specified nightly toolchain. The rest of project is compiled using the default toolchain, that is, the latest version of the stable
toolchain that you have installed.
If your computer is configured to use the latest Rust nightly
toolchain and you want to downgrade to a specific nightly version,you must first uninstall the latest nightly
toolchain. For example, you can remove the latest nightly
toolchain, then use a specific version of the nightly
toolchain by running commands similar to the following:
If after installing Rust the commands don't seem to work, showing errors such as command not found: rustup
, make sure it your PATH is configured correctly.
Currently, the rustup
installer installs by default to the bash profile (on mac). If you are using another shell, make sure to add this line to your profile (e.g. .zshrc
):
Currently, there are issues compiling the Substrate node when using the packages that are pre-installed on macOS computers with the M1 chip.
If you see this error, there are two solutions.
Install cmake
by running the following command:
Install the correct pre-compiled protoc
by running the following set of commands:
This environment also has the nightly-2020-10-06-x86_64-unknown-linux-gnu
toolchain installed, but this toolchain is only used if explicitly specified as a command-line option. For an example of specifying a specific toolchain as a command-line option, see .
Substrate uses (Wasm) to produce a portable blockchain runtime. You must configure the Rust compiler to use to allow you to compile Substrate runtime code to the Wasm target.
Running rustup update
updates both the nightly
and stable
toolchains to use the most recent release. If you are unable to compile the WebAssembly target after updating the nightly
toolchain, you can roll back to an earlier version of the toolchain and specify that version as a command-line option. For more information about getting an earlier version of the nightly
toolchain and specifying the version to use as a command-line option,.
If you want to guarantee that your build works on your computer as you update Rust and other dependencies, you should use a specific Rust nightly
toolchain that you know to be compatible with the version of Substrate you are using. How you identify and communicate the specific nightly
toolchain version to use for a project can vary. For example, Polkadot publishes this information in its .