Native VS Code integration with the Dev Containers extension.
Note: This guide targets VS Code. It has not been tested with Cursor or Google Antigravity.
- VS Code
- Dev Containers extension
- Docker installed and running
Podman alternative: On macOS, Podman works as a drop-in replacement for Docker Desktop. Install it via
brew install podman, then create adockeralias so the DevContainer CLI finds it:sudo ln -s $(which podman) /usr/local/bin/dockerSee From Docker to Podman: VS Code DevContainers for details.
-
Clone the repository:
git clone https://github.com/tarides/ocaml-devcontainer.git
-
Open in VS Code:
code ocaml-devcontainer
-
When prompted, click "Reopen in Container"
- Or: Press
Ctrl+Shift+P→ "Dev Containers: Reopen in Container"
- Or: Press
-
Wait for the container to start (~2-3 minutes first time)
The OCaml Platform extension is automatically installed and provides:
- Syntax highlighting
- Code completion
- Type information on hover
- Go to definition
- Find references
- Error diagnostics
For ThreadSanitizer support, open the .devcontainer-tsan/ configuration:
- Press
Ctrl+Shift+P→ "Dev Containers: Reopen in Container" - Select the "OCaml Development (TSan)" configuration
Then switch to the TSan compiler:
opam switch ocaml+tsan
eval $(opam env)Reload the window (Ctrl+Shift+P → "Developer: Reload Window") so the extension picks up the new switch.
See the README for details.
GDB and LLDB are available for native debugging. VS Code's debugger can be configured to use them.
The workspace folder is mounted from your host, so your files are always safe on disk. State inside the container (installed packages, shell history) persists as long as you stop and restart the container. Rebuilding the container (Ctrl+Shift+P → "Dev Containers: Rebuild Container") resets that state.
- Check that the container started successfully
- Reload the window
- Check the OCaml extension output panel
This can happen with large projects. Try:
dune build # Build first to generate .merlin files- Check Docker is running
- Try rebuilding:
Ctrl+Shift+P→ "Dev Containers: Rebuild Container" - Check Docker logs for errors
- Use
Ctrl+Shift+P→ "OCaml: Restart Language Server" if LSP gets confused - Use the "Problems" panel to see all errors and warnings
See the README for installed tools, common commands, and switch details.