On behalf of the entire opam team, but also with a personal sense of relief, I’m very pleased to announce that the process of upstreaming support for Windows OCaml to opam-repository in ocaml/opam-repository#25861 finally started on Friday!
There’s a full blog post with details on how you can try this out now with opam 2.2.0~beta2. The TL;DR, assuming you have winget on your Windows system (open the Microsoft Store app and install the App Installer package from Microsoft if you don’t) then you can issue:
winget install Git.Git
if you don’t have Git for Windows and:
winget install opam
if you don’t yet have the 2.2.0~beta2 binary. You must then launch a fresh Command Prompt / PowerShell session. For there, you can then run:
opam init git+https://github.com/dra27/opam-repository.git#windows-initial
or
opam init -a --no-git-location --cygwin-internal-install git+https://github.com/dra27/opam-repository.git#windows-initial
if you’d like to be asked fewer questions. There is a known and big pause when updating the repository. However, after a little bit of time (coffee, or a sword battle, if that’s your thing), you should then be faced with a fully initialised opam with ocaml-base-compiler.5.2.0 installed for the mingw-w64 amd64 port of native Windows opam.
Things with depexts will likely not work: the blog post contains details on how to get started with PRs, but issues are also helpful.
The blog post covers what we regard as the “default use case” - that is a native Windows user expecting to use this new OCaml thing they heard about natively. i.e. not running in WSL or Cygwin or MSYS2 or any other “are you sure can’t just install Linux on that?” approach.
However, all the other use cases matter too! You’re meant to be able to run native Windows opam from your own Cygwin or MSYS2 mintty bash terminal; we are aiming for the opam 2.2.0 binary to be a drop-in replacement (apart from setting os-distribution
to "cygwinports"
) for “OCaml for Windows” for legacy use with the “sunset” repository; you’re meant to be able to provide your own Cygwin or MSYS2 installation if you really need to (and you really might!). But we do need help testing all of it
We anticipate one further beta of opam 2.2.0 by the end of the month. From the Windows perspective, this will fix a known bug in the environment variable handling (see ocaml/opam#5838) but will also hopefully straighten out the behaviour of opam init
for some of these “non-default” use cases. We’re then hoping to rocket towards a release candidate in June
Happy Windows hacking! Please open issues; please ask for further help; please have fun!
David, on behalf of the opam team.