Skip to content

Instantly share code, notes, and snippets.

@mnxn
Last active March 2, 2024 01:53
Show Gist options
  • Save mnxn/93009346c1bd56f387daf28413152179 to your computer and use it in GitHub Desktop.
Save mnxn/93009346c1bd56f387daf28413152179 to your computer and use it in GitHub Desktop.
OCaml on MSYS2 (outdated)
  1. Install MSYS2

  2. Install required packages:

$ pacman -S rsync patch diffutils curl make unzip git m4 perl tar mingw-w64-cross-gcc mingw-w64-x86_64-pkg-config
  1. Add /opt/bin to $PATH:
$ echo 'export PATH=$PATH:/opt/bin' >> ~/.bashrc
  1. Restart the terminal or do source ~/.bashrc

  2. Download and extract the opam64 archive

$ curl -LO https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam64.tar.xz
$ tar xf opam64.tar.xz
  1. Run the opam install script. Ignore the messages about missing programs. MSYS2 installs packages differently from Cygwin.
$ bash opam64/install.sh
  1. Initialize the opam repository and set a default switch.
$ opam init default "https://github.com/fdopen/opam-repository-mingw.git#opam2" -c "ocaml-variants.4.10.0+mingw64c" --disable-sandboxing
  1. Allow opam to edit .bash_profile. (Press y)
Do you want opam to modify C:/dev/msys2/home/Max/.bash_profile? [N/y/f]
(default is 'no', use 'f' to choose a different file) y
  1. Allow opam to add the hook. (Press y)
A hook can be added to opam's init scripts to ensure that the shell remains in sync with the opam environment when they are loaded. Set that up? [y/N]
  1. Restart the terminal and you are ready to use OCaml in MSYS2.
@florianingerl
Copy link

I checked whether git is really installed with the command
"git --version" which gave "git version 2.43.2"

@mnxn
Copy link
Author

mnxn commented Feb 17, 2024

These instructions are very old, so it's entirely possible that they don't work anymore.

If you're just trying to install OCaml on Windows follow the official instructions here: https://ocaml.org/docs/ocaml-on-windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment