anchor/docs/src/getting-started/installation.md

84 lines
2.0 KiB
Markdown
Raw Normal View History

2021-01-02 22:40:17 -08:00
# Installing Dependencies
2021-01-02 16:24:35 -08:00
2021-01-02 22:40:17 -08:00
To get started, make sure to setup all the prerequisite tools on your local machine
(an installer has not yet been developed).
2021-01-02 16:24:35 -08:00
## Install Rust
2021-01-02 22:40:17 -08:00
For an introduction to Rust, see the excellent Rust [book](https://doc.rust-lang.org/book/).
2021-01-02 16:24:35 -08:00
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup component add rustfmt
```
2021-01-02 22:40:17 -08:00
## Install Solana
2021-01-02 16:24:35 -08:00
2021-04-18 12:13:07 -07:00
See the solana [docs](https://docs.solana.com/cli/install-solana-cli-tools) for installation instructions. On macOS and Linux,
2021-01-02 22:40:17 -08:00
```bash
2021-08-31 14:52:41 -07:00
sh -c "$(curl -sSfL https://release.solana.com/v1.7.11/install)"
2021-01-02 22:40:17 -08:00
```
2021-01-02 16:24:35 -08:00
2021-01-02 22:40:17 -08:00
## Install Mocha
Program integration tests are run using [Mocha](https://mochajs.org/).
2021-01-02 16:24:35 -08:00
```bash
2021-01-02 22:40:17 -08:00
npm install -g mocha
2021-01-02 16:24:35 -08:00
```
2021-01-02 22:40:17 -08:00
## Install Anchor
### Install using pre-build binary on x86_64 Linux
Anchor binaries are avalable via an NPM package [`@project-serum/anchor-cli`](https://www.npmjs.com/package/@project-serum/anchor-cli). Only x86_64 Linux is supported currently, you must build from source for other OS'.
```bash
npm i -g @project-serum/anchor-cli
```
### Build from source for other operating systems
2021-01-02 22:40:17 -08:00
For now, we can use Cargo to install the CLI.
2021-01-02 16:24:35 -08:00
```bash
2021-09-27 16:40:44 -07:00
cargo install --git https://github.com/project-serum/anchor --tag v0.16.2 anchor-cli --locked
2021-01-02 16:24:35 -08:00
```
2021-04-06 11:49:24 -07:00
On Linux systems you may need to install additional dependencies if `cargo install` fails. On Ubuntu,
2021-01-06 12:04:44 -08:00
```bash
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev
2021-01-06 12:04:44 -08:00
```
2021-01-02 22:40:17 -08:00
To install the JavaScript package.
2021-01-02 16:24:35 -08:00
2021-01-02 22:40:17 -08:00
```bash
npm install -g @project-serum/anchor
```
2021-01-04 18:29:16 -08:00
Make sure your `NODE_PATH` is set properly so that globally installed modules
can be resolved.
2021-08-22 18:22:28 -07:00
Now verify the CLI is installed properly.
```bash
anchor --version
```
## Start a Project
To initialize a new project, simply run:
```bash
anchor init <new-project-name>
```
## Minimum version requirements
| Build tool | Version |
|:------------|:---------------|
2021-06-10 20:01:25 -07:00
| Node.js | v11.0.0 |