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

**URL:** <https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558>\
**Category:** Ecosystem\
**Tags:** opam\
**Created:** [March 30, 2021, 8:41am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558 "2021-03-30T08:41:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![idkjs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/idkjs/32/675_2.png) [@idkjs](https://discuss.ocaml.org/u/idkjs)\
**Post date:** [March 30, 2021, 8:41am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/1 "2021-03-30T08:41:30Z")

</div>

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

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

```auto
[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.

```

And

```auto
 [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.

---

<div class="post-metadata">

**Author:** ![Khady](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/khady/32/469_2.png) [@Khady](https://discuss.ocaml.org/u/Khady)\
**Post date:** [March 30, 2021, 9:11am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/2 "2021-03-30T09:11:41Z")

</div>

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](https://github.com/melange-re/melange)

---

<div class="post-metadata">

**Author:** ![mseri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mseri/32/91_2.png) [@mseri](https://discuss.ocaml.org/u/mseri)\
**Post date:** [March 30, 2021, 9:14am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/3 "2021-03-30T09:14:19Z")

</div>

If `BS` means bucklescript, now [rescript](https://rescript-lang.org/blog/bucklescript-is-rebranding), 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](https://rescript-lang.org/docs/manual/latest/installation).

---

<div class="post-metadata">

**Author:** ![idkjs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/idkjs/32/675_2.png) [@idkjs](https://discuss.ocaml.org/u/idkjs)\
**Post date:** [March 30, 2021, 9:50am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/4 "2021-03-30T09:50:13Z")

</div>

[Here](https://github.com/reasonml-labs/decco/blob/0ffda3c343e2270abff44de32e229f91349744e4/ppx_src/package.json#L15-L23) is what I am talking about:

```json
  "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?

---

<div class="post-metadata">

**Author:** ![mseri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mseri/32/91_2.png) [@mseri](https://discuss.ocaml.org/u/mseri)\
**Post date:** [March 30, 2021, 9:55am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/5 "2021-03-30T09:55:26Z")

</div>

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](https://github.com/melange-re/ocaml). 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

---

<div class="post-metadata">

**Author:** ![idkjs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/idkjs/32/675_2.png) [@idkjs](https://discuss.ocaml.org/u/idkjs)\
**Post date:** [March 30, 2021, 10:07am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/6 "2021-03-30T10:07:38Z")

</div>

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 .`

---

<div class="post-metadata">

**Author:** ![mseri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mseri/32/91_2.png) [@mseri](https://discuss.ocaml.org/u/mseri)\
**Post date:** [March 30, 2021, 10:57am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/7 "2021-03-30T10:57:35Z")

</div>

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](https://github.com/ocaml/ocaml-pr-repository), and then added it as extra repository.

---

<div class="post-metadata">

**Author:** ![BikalGurung](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bikalgurung/32/5105_2.png) [@BikalGurung](https://discuss.ocaml.org/u/BikalGurung)\
**Post date:** [March 30, 2021, 11:05am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/8 "2021-03-30T11:05:03Z")

</div>

> [@idkjs](#):
>
> How does the `"ocaml": "4.12.0+BS"` get installed? Seem like running esy does the trick. Where is it getting it from?

This is specific to esy. Perhaps this should help you  
[https://esy.sh/docs/en/using-repo-sources-workflow.html](https://esy.sh/docs/en/using-repo-sources-workflow.html)

---

<div class="post-metadata">

**Author:** ![emillon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emillon/32/1206_2.png) [@emillon](https://discuss.ocaml.org/u/emillon)\
**Post date:** [March 30, 2021, 12:39pm UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/9 "2021-03-30T12:39:49Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![anmonteiro](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/anmonteiro/32/300_2.png) [@anmonteiro](https://discuss.ocaml.org/u/anmonteiro)\
**Post date:** [April 2, 2021, 4:19am UTC](https://discuss.ocaml.org/t/opam-switch-create-ocaml-variants-4-12-0-bs/7558/10 "2021-04-02T04:19:17Z")

</div>

Quick note to tie up a few loose ends here: after [PR#107](https://github.com/melange-re/melange/pull/107), Melange is installable in your regular (4.12) OPAM switch, and a forked compiler is no longer needed.
