Search code examples
ocamlopam

How to install a specific OCaml branch on github as an opam switch


After I asked a SO-question on periodic I/O buffer flushing in OCaml, I found out that the procedure I was proposing did not work reliably due to a bug in the OCaml runtime.

The good news: the bug was fixed in a development version, which is available on github.

Now, I could check that version out... but I'd prefer having a "opam switch".

How can I do that easily?


Solution

  • If I'm not mistaken, the version of the compiler used by a given switch is governed by one package among ocaml-base-compiler, ocaml-system-compiler and ocaml-variants. These packages can be handled, and in particular pinned, like any normal opam package. Thus, if you create an empty switch (e.g. opam switch create eintr-again --empty), and pin ocaml-variants to the branch you're interested in (opam pin add ocaml-variants https://github.com/stedolan/ocaml.git#eintr-again), you should obtain the compiler version you want in that switch.