Install

Before you can begin developing, it’s essential to prepare your development environment by installing the necessary compiler and tools. Since Substrate—and most of the tools used for Substrate development—are built using the Rust programming language, the first step is to install Rust on your computer.

The installation process for Rust varies depending on your operating system. Below are the instructions for each platform:

  • Linux

Here's an improved version of your Rust installation guide. I've organized the information more clearly, enhanced readability, and provided additional context where needed.

Rust Installation Guide for Linux

Before You Begin

Prerequisites

Before installing Rust, ensure your system meets the following requirements:

  1. Check Documentation: Refer to your operating system's documentation for information about installed packages and how to download and install any necessary packages.

  2. Required Packages: At a minimum, you need the following packages:

clang

curl

git

make

  1. Cryptography Support: Since blockchain development requires standard cryptography for generating public/private key pairs and validating transaction signatures, you also need a package that provides cryptography:

For Debian-based systems (like Ubuntu): libssl-dev

For Red Hat-based systems (like Fedora): openssl-devel

Install Required Packages

To install the necessary packages, follow these steps:

  1. Open a Terminal: Log on to your computer and open a terminal shell.

  2. Check Installed Packages: Use the appropriate package management command for your Linux distribution to check installed packages.

  3. Install Missing Dependencies: Run the following command to install the required packages. Adjust the command based on your distribution.

Example for Ubuntu:

sudo apt install --assume-yes git clang curl libssl-dev protobuf-compiler

Other Distributions:

  • Debian:

sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler
  • Arch:

sudo pacman -S git clang curl openssl protobuf
  • Fedora:

sudo dnf install git clang curl openssl-devel protobuf-compiler
  • OpenSUSE:

sudo zypper install git clang curl libopenssl-devel protobuf-compiler

Note:

Different distributions may use different package managers and package names. Ensure you adjust the commands accordingly.

Install Rust

  1. Download and Install rustup: Use the following command to download and install the Rust toolchain:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Follow the on-screen prompts to proceed with the default installation.

  1. Update Your Shell: To ensure your current shell session recognizes Cargo (Rust's package manager), run:

source $HOME/.cargo/env
  1. Verify Installation: Check that Rust is installed correctly by running:

rustc --version

Configure Rust Toolchain

  1. Set Default Toolchain: Configure the Rust toolchain to default to the latest stable version:

rustup default stable
rustup update
  1. Add Nightly Release and Targets: If you need nightly features or WebAssembly support, add the nightly release and targets:

rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
  1. Verify Configuration: Check your development environment configuration:

rustup show
rustup +nightly show

You should see output similar to:

   # rustup show
   active toolchain
   ----------------
   stable-x86_64-unknown-linux-gnu (default)
   rustc 1.62.1 (e092d0b6b 2022-07-16)

   # rustup +nightly show
   active toolchain
   ----------------
   nightly-x86_64-unknown-linux-gnu (overridden by +toolchain on the    command line)
   rustc 1.65.0-nightly (34a6cae28 2022-08-09)

You have successfully installed the Rust toolchain on your Linux system! You can now start developing Rust applications. For more resources and documentation, visit The Rust Programming Language.

  • macOS

Here's an improved version of your documentation for installing Rust on macOS. You can copy this text into Google Docs to save it in .docx format.

Rust Installation Guide for macOS

Before You Install

Before setting up your development environment on macOS, ensure your computer meets the following requirements:

  • Operating System: macOS 10.7 Lion or later

  • Processor Speed: At least 2 GHz (3 GHz recommended)

  • Memory: Minimum of 8 GB RAM (16 GB recommended)

  • Storage: At least 10 GB of available storage

  • Internet Connection: Broadband connection

  • Apple Silicon Support: Ensure your setup supports Apple Silicon.

Additionally, Protobuf must be installed before the build process begins. To install it, run the following command:

brew install protobuf

Install Homebrew

Homebrew is the recommended package manager for macOS. If you don't have it installed, follow these steps:

  1. Open Terminal: Launch the Terminal application on your Mac.

  2. Install Homebrew: Run the following command to download and install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  1. Verify Installation: Check that Homebrew is installed successfully by running:

brew --version

You should see output similar to:

Installation of Rust and Dependencies

To set up Rust and its dependencies, follow these steps:

  1. Open Terminal: Ensure you are in the Terminal application.

  2. Update Homebrew: Make sure Homebrew is up to date by running:

brew update
  1. Install OpenSSL: Install the OpenSSL package:

brew install openssl
  1. Install Rust: Download the rustup installation program and use it to install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Follow Prompts: Follow the on-screen prompts to complete the default installation.

  2. Update Shell: Include Cargo in your current shell session:

source ~/.cargo/env
  1. Verify Installation: Confirm that Rust is installed correctly by running:

 rustc --version

Configure the Rust Toolchain

  1. Set Default Toolchain: Configure the Rust toolchain to use the latest stable version:

   rustup default stable
   rustup update
   rustup target add wasm32-unknown-unknown
  1. Add Nightly Release and Targets: To include nightly features and WebAssembly support, run:

   rustup update nightly
   rustup target add wasm32-unknown-unknown --toolchain nightly
  1. Verify Configuration: Check your Rust environment configuration:

   rustup show
   rustup +nightly show

You should see output similar to:

   # rustup show
   active toolchain
   ----------------
   stable-x86_64-apple-darwin (default)
   rustc 1.61.0 (fe5b13d68 2022-05-18)

   # rustup +nightly show
   active toolchain
   ----------------
   nightly-x86_64-apple-darwin (overridden by +toolchain on the command line)
   rustc 1.63.0-nightly (e71440575 2022-06-02)

Install CMake

To complete your setup, install CMake with the following command:

brew install cmake

Last updated