How to execute a programme in VSCode+OCaml Platform

I try to use VSCode with OCaml Platform, but when trying to execute it (Execute, Execute without debugging), VSCode ask me to select one of the “environment” : Chrome, Edge, Node.js, EarlybirdOCaml, Python.

The only OCaml related environment is EarlybirdOCaml, but it displays the error Unsupported file format.

The only way is to open a terminal, and type commands needed to run my simple program (or compile a whole project if I have something more complicated).


The OCaml Platform extension does not support building and running your programs using “Run and Debug” at this time. So there’re two alternative ways:

  1. Build in terminal as you please.
  2. Use a VS Code “task.” You can do so by first invoking VS Code Command Palette (cmd + shift + p on mac, and ctrl + shift + p on windows I suppose), finding and clicking on an action “Tasks: Configure Default Build Task”. The extension should suggest you a couple of possible tasks based on your dune files (dune, dune-project), you can pick one, which will create a task for you to build your (sub)-project.

Any way, I find just keeping a vscode terminal with “dune build --watch” running.

If you haven’t checked out the Getting Started section of the OCaml Platform extension, you find it useful.