# Mina build instructions (Ubuntu 20.04)
Mina's reference implementation is written in Ocaml. This document contains instructions for setting up a mina development environment on Ubuntu 20.04.
## Clone the repo
(These were done on `develop` branch, last commit hash 6ca0831 as of writing this doc):
`git clone https://github.com/MinaProtocol/mina`
`cd mina`
`git submodule update --init --recursive`
`git config --local --add submodule.recurse true`
## Install required OS libs
https://github.com/MinaProtocol/mina/blob/a42bdee/dockerfiles/Dockerfile-toolchain
```
sudo apt-get update && sudo apt-get install --yes \
cmake \
jq \
libboost-dev \
libboost-program-options-dev \
libffi-dev \
libgmp-dev \
libgmp3-dev \
libjemalloc-dev \
libpq-dev \
libprocps-dev \
libsodium-dev \
libssl-dev \
lsb \
m4 \
nodejs \
pandoc \
patchelf \
python \
perl \
pkg-config \
python-jinja2 \
python-pip \
python3-pip \
rubygems \
zlib1g-dev \
libbz2-dev \
apt-transport-https
```
## Setup ocaml
`sudo apt-get install ocaml`
## Setup opam 2.0.7
```
add-apt-repository ppa:avsm/ppa
apt update
apt install opam
opam init
```
Refer to https://opam.ocaml.org/doc/Install.html for details
## Setup dependencies and pins for OPAM
```shell
$ sh scripts/setup-opam.sh
```
## Setup golang (go1.17.2 linux/amd64)
This is required for mina's capnproto dependency.
## Setup capnproto-go binary compiler in /usr/local/bin
https://github.com/MinaProtocol/mina/blob/6ca0831c50d8860e20837c71092ccf45a9d902e3/dockerfiles/stages/1-build-deps#L127
## Install cargo and rustc 1.45.2
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envrust
rustup toolchain install 1.45.2 && rustup default 1.45.2
```
## Build the mina daemon
```shell
# set this env var to build the binary for mainnet
$ DUNE_PROFILE=mainnet
# this should build the mina binary as `_build/default/src/app/cli/src/mina.exe`
$ make build
```
## Run mina daemon
```shell
$ _build/default/src/app/cli/src/mina.exe
```
## Run mina daemon as a seed node with peer list
```shell
$ _build/default/src/app/cli/src/mina.exe daemon --peer-list-url https://storage.googleapis.com/mina-seed-lists/mainnet_seeds.txt --seed
```
## VSCode setup
Install ocaml platform extension: https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform
Also install `opam install ocaml-lsp-server` in terminal
Select the right ocaml sandbox/switch from extension 4.11.2 using the ocaml button on left.
Run `eval $(opam env)` on terminal to make sure the environment is recognized.
The autocomplete and jump to definition should work.
## Report any issues below