`opam switch create ocaml-variants.4.12.0+BS`

Where would I find ocaml-variants.4.12.0+BS?

Running opam switch create ocaml-variants.4.12.0+BS gets me:

[I] ➜ opam switch create 4.12.0+BS ocaml-variants.4.12.0+BS
[ERROR] No compiler matching 'ocaml-variants.4.12.0+BS' found, use 'opam
        switch list-available' to see what is available, or use '--packages'
        to select packages explicitly.


 [I] ➜ opam switch create 4.12.0+BS --packages ocaml-variants.4.12.0+BS
[ERROR] ocaml-variants = 4.12.0+BS no matching version

Thank you.

If the rescript team doesn’t publish a new version of their compiler on opam, you won’t be able to find it. For now I believe that they are still based on 4.06. And I don’t know if they plan to still publish to opam in the future. The closest thing that you can look for is GitHub - melange-re/melange: A mixture of tooling combined to produce JavaScript from OCaml & Reason

1 Like

If BS means bucklescript, now rescript, I don’t think we have ever had such variants in the opam repository and, besides, rescript is built upon an older version of the compiler (I think 4.06 or 4.08, but I may be wrong). The recommended way to install it is described on the rescript website.

Here is what I am talking about:

  "devDependencies": {
    "@opam/reason": "^3.7.0",
    "@opam/dune": ">=2.8.4",
    "@opam/ppxlib": "^0.22.0",
    "ocaml": "4.12.0+BS"
  "resolutions": {
    "ocaml": "anmonteiro/ocaml#75f22c872451c66a4c4aadc43abee55697268a57"

How does the "ocaml": "4.12.0+BS" get installed? Seem like running esy does the trick. Where is it getting it from?

1 Like

The secret is in the resolution line which tricks way into resolving the package to a specific commit of GitHub - melange-re/ocaml: The core OCaml system: compilers, runtime system, base libraries. So this is not going to work with opam as it stands, @anmonteiro can give you more details about that.

PS I know how to pin packages in opam but not sure how one can do that for ocaml variants without creating an overlay opam-repository


Thanks @mseri. Figured some magic in there and was wondering what it was.

So the compiler exists somwhere but there isn’t a way to download on its own and do an opam pin add .

There probably is a way, maybe @kit-ty-kate or @AltGr know by heart.

The way I did it in the past is a bit cumberson: I created an overlay opam-repository only containing the compiler variants that I needed, mocking what was done for GitHub - ocaml/ocaml-pr-repository: opam switches for all the proposed pull requests against the compiler, and then added it as extra repository.

This is specific to esy. Perhaps this should help you

1 Like

I know nothing about bucklescript or melange so I don’t know if it’s enough, but the following command will create a switch named melange from a git reference:

% opam update
% opam compiler create 'anmonteiro/ocaml:75f22c872451c66a4c4aadc43abee55697268a57' --switch melange
% ocaml -version
The OCaml toplevel, version 4.12.0+BS

Quick note to tie up a few loose ends here: after PR#107, Melange is installable in your regular (4.12) OPAM switch, and a forked compiler is no longer needed.