Skip to content

Install

You need opam, OCaml’s package manager, OCaml 5.5 or later, and a Postgres server to connect to. postgres-eio brings dune, the build tool, with it.

Terminal window
brew install opam
Terminal window
opam init

Answer yes when it offers to set up your shell. This installs the latest OCaml, which takes a few minutes. Then let this terminal see it – a new terminal does by itself:

Terminal window
eval $(opam env)
Already had opam?

Check ocaml -version. If it is older than 5.5, make a switch – an environment of its own – with the latest OCaml:

Terminal window
opam switch create postgres-eio ocaml-base-compiler
eval $(opam env)
Terminal window
opam repo add hypha https://github.com/hyphatech/opam-repository.git
opam install postgres-eio

This installs the driver and everything it needs. A program runs it inside Eio’s event loop, which eio_main starts, so install that beside it:

Terminal window
opam install eio_main

A program names both in its dune file:

(libraries postgres-eio eio_main)
Terminal window
$ ocaml -version
The OCaml toplevel, version 5.5.1
$ opam list postgres-eio

It lists postgres-eio with a version, not --, under Installed.

For completion, types on hover and errors as you type, install the language server, then the OCaml Platform extension in VS Code – or the OCaml support of your editor:

Terminal window
opam install ocaml-lsp-server

The quick start connects and runs a query, next.