Skip to main content


OCaml Development on Windows

Some statements

We all have our own constraints when it comes to development tooling, so we compromise.
In my case, I like Linux and Mac OS, but I often have to work on Windows.
It’s no secret that Windows sucks for development, specially for modern web development.
Windows Subsystem for Linux (WSL) helps a lot, but it has its limits.

OCaml is no exception on Windows sucking for development, the installation build breaks even on WSL, that’s what we’ll fix today.

Down to it!

OCaml in WSL

  1. Get the Ubuntu WSL from the Microsoft Store
    Excuse my French! Microsoft store ubuntu

  2. Launch it, it should ask you for some stuff like a username and password

  3. Now in the Linux shell, let’s install some dependencies

$ sudo apt-get install curl build-essential m4 zlib1g-dev libssl-dev bubblewrap
  1. Let’s install opam, the OCaml version and package manager. It exists in the default Ubuntu package repositories, but it’s an old version, so we’ll get it from the installation script better.
$ sh <(curl -sL
  1. Initialize opam
$opam init --disable-sandboxing
  1. Find the Latest Release Version Try
opam switch list-available

The latest stable version is the latest release without a +<something>.

  1. Install the Latest OCaml
$ opam switch create 4.10.0 --jobs=1

We’re purposedly not using concurrent jobs because it breaks on WSL.

  1. This is it!
$ opam switch
#  switch   compiler                    description
→  4.10.0   ocaml-base-compiler.4.10.0  4.10.0

Editor Configuration

  1. Visual Studio Code … Not much way around this… Thankfully it’s a pretty good editor, in this case, there’s a WSL plugin that uses a VSCode server in WSL so you can edit your files from Windows.
    You can download the editor from here.

  2. Install the Remote - WSL Plugin

  3. Open Your Project Directory Now, from any directory in the WSL shell, you should be able to run the code command, and it will open VSCode in Windows on this directory/file.