[pre-ANN] Installing Windows OCaml 5.0.0 in opam

One of opam 2.2’s headline features is that both “upstream” opam (i.e. opam built from un-patched sources from ocaml/opam) and “un-forked” opam-repository (i.e. ocaml/opam-repository) finally provide native Windows opam switches. We’re aiming to get an alpha release of this out in the coming weeks, but I’ve had various requests directly for how to use OCaml 5.0 with opam-repository-mingw in the meantime, so I’m just sharing this temporary solution, in case it’s of use to others.

I have a demonstration workflow at GitHub - dra27/ocaml5-ci-demo with setup-ocaml. It shows the commands necessary for local use:

      - run: opam repo add dra27 git+https://github.com/dra27/opam-repository#windows-5.0 --all --set-default
      - run: opam switch create 5.0 --packages=ocaml.5.0.0,ocaml-option-mingw
      - run: opam exec --switch=5.0 -- ocamlopt -config
      - run: opam install --switch=5.0 utop

and also how to use it directly in a workflow:

      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v2
        with:
          ocaml-compiler: ocaml.5.0.0,ocaml-option-mingw
          opam-repositories: |
            dra27: https://github.com/dra27/opam-repository.git#windows-5.0
            default: https://github.com/fdopen/opam-repository-mingw.git#opam2

The windows-5.0 branch adds just enough to provide the OCaml 5.0.0 package for mingw-w64 by patching ocaml-variants.5.0.0+options (rather than providing ocaml-variants.5.0.0+mingw64). Unless you expressly select ocaml-variants.5.0.0+options, it’ll actually pick up a version patched with ocaml/ocaml#11846.

The only change once the alpha release comes out should be the removal of the opam repo add dra27 part.

15 Likes