How to setup Emacs ReasonML development environment in Ubuntu 16

Dmytro Gladkyi
2 min readDec 29, 2017

--

** Update on 27.04.2018. These instructions work for the previous releases of ReasonML (Reason CLI 3.0.4). They might not work with the newest releases**

Emacs has a great support for ReasonML via reason-mode.

But installing reason-mode is not enough. Other tools must be installed and configured to open all possibilities.

Following steps were performed on DigitalOcean’s $20 instance (with 3Gb of RAM). If you want to use cheaper instances, then you will not be able to install bs-platform, as it’s compilation process eats a lot of RAM and will fail for you.

1. Install Reason toolchain: https://github.com/reasonml/reason-cli:

npm install -g https://github.com/reasonml/reason-cli/archive/3.0.4-bin-linux.tar.gz

This command installs different tools, which are later used by Emacs’s reason-mode.

2. Install a package manager for OCaml: https://opam.ocaml.org/doc/Install.html.

3. Install merlin: https://github.com/ocaml/merlin. This is an IDE plugin for Emacs/Vim.

opam install merlin

opam user-setup install

Follow all the instructions, provided by installer. You have to update .emacs file with the commands, provided by the installer (it updates file automatically).

4. Install BuckleScript Platform:

npm install -g bs-platform

5. Install auto-complete, company, merlin-mode, reason-mode in Emacs.

To install reason-mode via Emacs package manager, you have to add MELPA repository to your Emacs. Instructions are provided here: https://melpa.org/#/getting-started

6. Setup reason-mode for Emacs with these instructions:

Pay attention, that you need to update .emacs file again with reason/merlin setup. Copy and paste that whole section with Reason Setup instructions into your .emacs file.

BUT, for Ubuntu 16.04 there was such issue: “refmt — — where” could not be executed by Emacs, and setup process failed. I had to remove (shell-cmd “refmt — — where”) and (shell-cmd “camlmerlin — — where”) expressions from .emacs file.

After this, I finally could use all the possibilities of merlin and reason modes in Emacs :-)

I ended with such .emacs file:

--

--