Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 4.32 KB

setup-linux.md

File metadata and controls

129 lines (98 loc) · 4.32 KB

Developer Setup (Linux)

Native Linux build instructions (Ubuntu-flavoured by default).

Consider Docker or Nix first. The Docker dev environment pins the same toolchain CI uses and handles the system dependency matrix for you; Nix does the same declaratively. The native path below is a best-effort starting point — the canonical install steps are what's run in dockerfiles/toolchain/, and this doc can drift behind them when CI adds or bumps a system dep. If you hit a missing dependency, please open a PR updating this page.

Prerequisites

This guide assumes you have already cloned the repo and pulled in submodules. If not, see the "Clone the repo" section of README-dev.md.

A reasonably recent Ubuntu (or compatible distro) is expected. Mina has historically been developed against Ubuntu LTS releases.

System dependencies

Mina has a variety of opam and system dependencies. A number of C libraries are expected to be available in the system; the canonical list is what's installed by dockerfiles/toolchain/1-build-deps — if you suspect a missing dep, grep that file for the matching apt install line. Most of these are installed via apt; RocksDB is installed automatically as a dune rule in the ocaml-rocksdb library.

If you need Docker for building containers later (e.g. local Docker images), follow the official Docker CE for Ubuntu instructions.

opam switch

To get all of the required opam dependencies, run:

opam repository add --yes --all --set-default o1-labs https://github.com/o1-labs/opam-repository.git
opam switch import opam.export

Note: the switch provides a dune_wrapper binary that you can use instead of dune and which fails early if your switch becomes out of sync with the opam.export file.

Some dependencies that are not taken from opam or integrated with dune must be added manually. Run:

scripts/pin-external-packages.sh

Build

make build

For a quick type-check without a full build:

dune build @check

IDE setup (Merlin, LSP)

The IDE configuration is OS-independent — these instructions apply on both Linux and macOS.

vim

Add this snippet in your .vimrc (change the home directory to match yours):

let s:ocamlmerlin="/Users/USERNAME/.opam/4.14.2/share/merlin"
execute "set rtp+=".s:ocamlmerlin."/vim"
execute "set rtp+=".s:ocamlmerlin."/vimbufsync"
let g:syntastic_ocaml_checkers=['merlin']

Then:

  • In your home directory, run opam init.
  • In this shell, eval $(opam config env).
  • Install autocomplete dependencies: opam install merlin ocp-indent core async ppx_jane ppx_deriving.
  • Make sure you have au FileType ocaml set omnifunc=merlin#Complete in your .vimrc.
  • Install an auto-completer (such as YouCompleteMe) and a syntastic (such as syntastic or ALE).

Emacs

Install the opam packages mentioned above and also install tuareg. Add the following to your .emacs file:

(let ((opam-share (ignore-errors (car (process-lines "opam" "var" "share")))))
  (when (and opam-share (file-directory-p opam-share))
    ;; Register Merlin
    (add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
    (load "tuareg-site-file")
    (autoload 'merlin-mode "merlin" nil t nil)
    ;; Automatically start it in OCaml buffers
    (add-hook 'tuareg-mode-hook 'merlin-mode t)
    (add-hook 'caml-mode-hook 'merlin-mode t)))

To use the Emacs built-in autocomplete, use M-x completion-at-point or M-tab. There are other Emacs autocompletion packages; see Emacs from scratch.

VSCode

  • Make sure you're in the right opam switch (mina).
  • Add the OCaml Platform extension.
  • You might get a prompt to install ocaml-lsp-server in the Sandbox — accept.
  • You might get a prompt to install ocamlformat-rpc in the Sandbox — accept.
  • Type "shell command:install code command in PATH".
  • Close all windows and instances of VSCode.
  • From terminal, in your mina directory, run code ..
  • Run dune build in the terminal inside VSCode.