Yao Lirong's Blog

Installing and Configuring Ocaml on Linux

2020/01/20

Install Ocaml

run sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) and install opam at /usr/bin (Caution: install it under this directory to ensure you can also access opam at user’s directory)

Configure Ocaml and VSCode

  1. initiate with sandbox (bubblewrap) disabled opam init --bare -a -y --disable-sandboxing

  2. switch OPAM to the OCaml 4.09.0 compiler:

    1
    2
    3
    # Note: do NOT prefix these commands with sudo
    opam switch create 4.09.0 ocaml-base-compiler.4.09.0
    eval $(opam env)
  3. install OPAM packages needed

    1
    2
    opam install -y utop ounit qtest yojson lwt lwt_ppx menhir ansiterminal lambda-term merlin ocp-indent user-setup bisect_ppx-ocamlbuild
    opam user-setup install
  4. install “OCaml and Reason IDE” and configure settings.json in vscode as such:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    {
    "workbench.colorTheme": "Solarized Light",
    "editor.tabSize": 2,
    "editor.rulers": [
    80
    ],
    "editor.formatOnSave": true,
    "reason.path.ocamlmerlin": "/home/mint/.opam/4.09.0/bin/ocamlmerlin",
    "reason.path.ocamlfind": "/home/mint/.opam/4.09.0/bin/ocamlfind"
    }

    note that it first showed that “cannot locate ocamlmerlin binary.” I fixed the problem by changing directory of “ocamlmerlin” and “ocamlfind” in the settings. (Find their path with which ocamlmerlin)

CATALOG
  1. 1. Install Ocaml
  2. 2. Configure Ocaml and VSCode