Where would I find
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
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:
How does the
"ocaml": "4.12.0+BS" get installed? Seem like running esy does the trick. Where is it getting it from?
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
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.