> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/solana-foundation/anchor/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Learn how to install Rust, the Solana CLI, and Anchor Framework on Windows (WSL), Linux, or Mac

This guide covers the steps to set up your local environment for Solana development with Anchor.

## Quick installation

On Mac and Linux, run this single command to install all dependencies:

```shell theme={null}
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash
```

<Warning>
  Windows users must first install WSL (see [Install Dependencies](#install-dependencies)). Then run the command above in the Ubuntu (Linux) terminal.
</Warning>

After installation, you should see output similar to:

```
Installed Versions:
Rust: rustc 1.85.0 (4d91de4e4 2025-02-17)
Solana CLI: solana-cli 2.1.15 (src:53545685; feat:3271415109, client:Agave)
Anchor CLI: anchor-cli 0.32.1
Node.js: v23.9.0
Yarn: 1.22.1

Installation complete. Please restart your terminal to apply all changes.
```

<Info>
  If the quick installation doesn't work, refer to the [Install Dependencies](#install-dependencies) section below for instructions to install each dependency individually.

  If the quick install succeeds, skip to [Solana CLI Basics](#solana-cli-basics) and [Anchor CLI Basics](#anchor-cli-basics).
</Info>

## Install dependencies

The instructions below guide you through installing each dependency individually.

* **Windows users**: First install WSL (Windows Subsystem for Linux), then install the dependencies specified in the Linux section
* **Linux users**: First install the dependencies specified in the Linux section below
* **Mac users**: Start with the Rust installation instructions

### Windows Subsystem for Linux (WSL)

To develop Solana programs on Windows, you must use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install). All additional dependencies must be installed through the Linux terminal.

To install WSL, run this command in Windows PowerShell:

```shell theme={null}
wsl --install
```

By default, WSL installs Ubuntu. Open a Linux terminal by searching "Ubuntu" in the search bar.

<Info>
  If you're using VS Code, the [WSL extension](https://code.visualstudio.com/docs/remote/wsl-tutorial) enables you to use WSL and VS Code together.
</Info>

### Linux dependencies

The following dependencies are required for the Anchor CLI installation.

First, update your package manager:

```shell theme={null}
sudo apt-get update
```

Next, install the required dependencies:

```shell theme={null}
sudo apt-get install -y \
    build-essential \
    pkg-config \
    libudev-dev llvm libclang-dev \
    protobuf-compiler libssl-dev
```

<Steps>
  ### Install Rust

  Solana programs are written in the [Rust programming language](https://www.rust-lang.org/).

  The recommended installation method for Rust is [rustup](https://www.rust-lang.org/tools/install).

  Run the following command to install Rust:

  ```shell theme={null}
  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  ```

  Reload your PATH environment variable:

  ```shell theme={null}
  . "$HOME/.cargo/env"
  ```

  Verify the installation:

  ```shell theme={null}
  rustc --version
  ```

  You should see output similar to:

  ```
  rustc 1.84.1 (e71f9a9a9 2025-01-27)
  ```

  ### Install Solana CLI

  The Solana CLI provides all the tools required to build and deploy Solana programs.

  Install the Solana CLI tool suite:

  ```shell theme={null}
  sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
  ```

  You can replace `stable` with a specific release tag (e.g., `v2.0.3`) or use `beta` or `edge`.

  <Tabs items={["Linux", "Mac"]}>
    <Tab value="Linux">
      If prompted, add the PATH environment variable:

      ```shell theme={null}
      export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
      ```
    </Tab>

    <Tab value="Mac">
      On Mac using `zsh`, add the PATH to your shell configuration:

      ```shell theme={null}
      echo 'export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"' >> ~/.zshrc
      ```

      Then refresh your terminal session:

      ```shell theme={null}
      source ~/.zshrc
      ```
    </Tab>
  </Tabs>

  Verify the installation:

  ```shell theme={null}
  solana --version
  ```

  You should see output similar to:

  ```
  solana-cli 2.0.26 (src:3dccb3e7; feat:607245837, client:Agave)
  ```

  To update the Solana CLI later:

  ```shell theme={null}
  agave-install update
  ```

  ### Install Anchor CLI

  [Anchor](https://www.anchor-lang.com/) is a framework for developing Solana programs. The Anchor framework leverages Rust macros to simplify the process of writing Solana programs.

  There are two ways to install the Anchor CLI:

  1. **Anchor Version Manager (AVM)** - Recommended
  2. **Without AVM** - Install directly from GitHub

  <Tabs items={["AVM", "Without AVM"]}>
    <Tab value="AVM">
      The Anchor version manager (AVM) allows you to install and manage different Anchor versions.

      Install AVM:

      ```shell theme={null}
      cargo install --git https://github.com/coral-xyz/anchor avm --force
      ```

      Check that AVM was installed successfully:

      ```shell theme={null}
      avm --version
      ```

      Install the latest version of Anchor CLI:

      ```shell theme={null}
      avm install latest
      avm use latest
      ```

      Alternatively, install a specific version:

      ```shell theme={null}
      avm install 0.32.1
      avm use 0.32.1
      ```

      <Info>
        Don't forget to run `avm use` to declare which Anchor CLI version should be used on your system.
      </Info>
    </Tab>

    <Tab value="Without AVM">
      Install a specific version of the Anchor CLI:

      ```shell theme={null}
      cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli
      ```
    </Tab>
  </Tabs>

  Verify the installation:

  ```shell theme={null}
  anchor --version
  ```

  You should see output similar to:

  ```
  anchor-cli 0.32.1
  ```

  #### Node.js and Yarn

  Node.js and Yarn are required to run the default Anchor project test file (TypeScript) created with the `anchor init` command.

  **Install Node.js:**

  The recommended way to install Node.js is using [Node Version Manager (nvm)](https://github.com/nvm-sh/nvm):

  ```shell theme={null}
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
  ```

  Restart your terminal and verify nvm is installed:

  ```shell theme={null}
  command -v nvm
  ```

  Use nvm to install Node:

  ```shell theme={null}
  nvm install node
  ```

  Verify the installation:

  ```shell theme={null}
  node --version
  ```

  **Install Yarn:**

  ```shell theme={null}
  npm install --global yarn
  ```

  Verify the installation:

  ```shell theme={null}
  yarn --version
  ```
</Steps>

## Solana CLI basics

This section walks through common Solana CLI commands to get you started.

<Steps>
  ### Solana config

  View your current config:

  ```shell theme={null}
  solana config get
  ```

  You should see output similar to:

  ```
  Config File: /Users/test/.config/solana/cli/config.yml
  RPC URL: https://api.mainnet-beta.solana.com
  WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
  Keypair Path: /Users/test/.config/solana/id.json
  Commitment: confirmed
  ```

  Update the Solana CLI cluster:

  ```shell theme={null}
  solana config set --url mainnet-beta
  solana config set --url devnet
  solana config set --url localhost
  solana config set --url testnet
  ```

  Or use short options:

  ```shell theme={null}
  solana config set -um    # For mainnet-beta
  solana config set -ud    # For devnet
  solana config set -ul    # For localhost
  solana config set -ut    # For testnet
  ```

  ### Create wallet

  To interact with the Solana network, you need a wallet funded with SOL.

  Generate a keypair at the default location:

  ```shell theme={null}
  solana-keygen new
  ```

  Get the address (public key) of your keypair:

  ```shell theme={null}
  solana address
  ```

  ### Airdrop SOL

  Request an airdrop of SOL to fund your wallet on devnet:

  ```shell theme={null}
  solana config set -ud
  solana airdrop 2
  ```

  Check your wallet's SOL balance:

  ```shell theme={null}
  solana balance
  ```

  <Info>
    The `solana airdrop` command is limited to 5 SOL per request on devnet. Alternatively, use the [Solana Web Faucet](https://faucet.solana.com).
  </Info>

  ### Run local validator

  Run a local validator to deploy and test programs locally:

  ```shell theme={null}
  solana-test-validator
  ```

  In a separate terminal, update the Solana CLI config to localhost:

  ```shell theme={null}
  solana config set -ul
  ```
</Steps>

## Anchor CLI basics

This section walks through common Anchor CLI commands.

<Steps>
  ### Initialize project

  Create a new Anchor project:

  ```shell theme={null}
  anchor init <project-name>
  ```

  For example:

  ```shell theme={null}
  anchor init my-project
  ```

  This creates a new directory with a modular Rust program structure and TypeScript test template.

  Navigate to the project directory:

  ```shell theme={null}
  cd my-project
  ```

  ### Build program

  Build your project:

  ```shell theme={null}
  anchor build
  ```

  The compiled program will be in `/target/deploy`.

  ### Deploy program

  Deploy your project:

  ```shell theme={null}
  anchor deploy
  ```

  This deploys your program to the cluster specified in the `Anchor.toml` file.

  ### Test program

  Test your project:

  ```shell theme={null}
  anchor test
  ```

  This command builds, deploys, and runs tests. When using `localnet`, Anchor automatically starts a local validator, deploys your program, runs tests, and stops the validator.
</Steps>

## Next steps

Now that you have your development environment set up, continue to the [Quickstart](/quickstart) guide to build your first Anchor program.
