# Rust and Difinity Installation process for Canister Development in ICP.

#### **1.2.1 Installing Rust**

Before diving into creating ICP Canisters with Rust, let's set up your Rust development environment to ensure a smooth workflow. Rust offers a powerful toolset for system-level programming and web development alike. We'll install Rust and configure it for the project.

Rust comes with a dedicated package manager called "Cargo" that makes managing dependencies and building projects a breeze. If you already have Rust set up, you can skip this step.

To install Rust, we'll use rustup, the official Rust toolchain installer. Run the following command in your terminal to install Rust:

```bash
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
```

After running the command, you should see a welcome message, that will ask you how to proceed with the installation:

```bash
1...
2
3Current installation options:
4
5   default host triple: x86_64-unknown-linux-gnu
6     default toolchain: stable (default)
7               profile: default
8  modify PATH variable: yes
9
101) Proceed with installation (default)
112) Customize installation
123) Cancel installation
13>
```

Press 1 and hit enter or just directly press enter to proceed with the installation since 1 is selected as default.

After the installation is complete, you should see a similar output in your terminal:

```bash
1
2Rust is installed now. Great!
3
4To get started you may need to restart your current shell.
5This would reload your PATH environment variable to include
6Cargo's bin directory ($HOME/.cargo/bin).
7
8To configure your current shell, run:
9source "$HOME/.cargo/env"
```

Next run the source command to ensure that the necessary environment variables are loaded:

```bash
source "$HOME/.cargo/env"
```

This completes the installation of Rust. In the next section, we'll install the necessary dependencies for our project.

#### **1.2.2 Installing wasm32-unknown-unknown target**

Next, we need to install the wasm32-unknown-unknown target, which is a WebAssembly target for the Rust programming language. So that we can compile Rust code to WebAssembly and run it on the Internet Computer.

Run the following command to install the wasm32-unknown-unknown target:

```bash
rustup target add wasm32-unknown-unknown
```

#### **1.2.3 Installing Candid Extractor**

Next, we need to install Candid Extractor, a tool which allows you to extract Candid interface definitions from WebAssembly modules. This enables us to generate Candid interface definitions for our canister to interact with it.

Run the following command to install Candid Extractor:

```bash
cargo install candid-extractor
```

#### **1.2.4 Installing DFX**

We'll also need DFX, a command-line interface for the Internet Computer. DFX allows you to create, build, deploy, and manage canisters on the platform. It also offers a local development environment for testing.

Install DFX by running:

```bash
DFX_VERSION=0.15.0 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
```

Now that we have DFX installed, you need to add it to your path. Run the following command:

```bash
echo 'export PATH="$PATH:$HOME/bin"' >> "$HOME/.bashrc"
```

#### **1.2.6 Ensuring Everything is Installed Correctly**

1. **Close and Reopen Your Terminal:** Close and reopen your terminal to ensure the new environment variables are loaded.
    
2. **Check the Installed Rust Version:** Run the following command to check the installed Rust version:
    
    ```bash
    cargo --version
    ```
    
    You should see something like this:
    
    ```bash
    cargo 1.72.0 (103a7ff2e 2023-08-15)
    ```
    
3. **Check the Installed DFX Version:** Run the following command to check the installed DFX version:
    
    ```bash
    dfx --version
    ```
    
    You should see something like this:
    
    ```bash
    dfx 0.15.0
    ```
    

With all the dependencies installed, we're ready to start building our canister.
