Skip to content

Instantly share code, notes, and snippets.

Created Dec 21, 2017
What would you like to do?
Install OCaml 4.06 in a Win10 VM with vagrant
# Download vagrant box for Windows 10 from:
# Unzip and add with:
# vagrant box add --name win10 MSEdge\ -\
# During the first `vagrant up` need to connect to vm UI to do this:
# Otherwise the up timesout (it should be possible to make a new vagrant box
# just after that has been done)
Vagrant.configure("2") do |config| = "win10"
config.vm.guest = :windows
# Setup WinRM
config.vm.communicator = "winrm"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
# Setup SSH
config.ssh.username = "IEUser"
config.ssh.password = "Passw0rd!"
config.ssh.insert_key = true
config.vm.provider "virtualbox" do |vb| = "Win10 - OCaml 4.06"
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Install chocolatey
$chocolatey = <<-'SCRIPT'
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(''))
config.vm.provision :shell, inline: $chocolatey
# Install a few packages and sed and make in cygwin
$chocopkgs = <<-'SCRIPT'
chocolatey feature enable -n=allowGlobalConfirmation
choco install git
choco install visualstudio2017buildtools
choco install visualstudio2017-workload-vctools
choco install cygwin
choco install cyg-get
chocolatey feature disable -n=allowGlobalConfirmation
cyg-get sed make
config.vm.provision :shell, inline: $chocopkgs
# Install OCaml from source in C:\ocamlms64\bin
$ocaml = <<-'SCRIPT'
# The following to avoid problems with sed in OCaml's build system.
git config --global core.autocrlf false
git config --global core.eol lf
git clone -b 4.06.0 ocaml
cd ocaml
git submodule update --init
copy config\m-nt.h byterun\caml\m.h
copy config\s-nt.h byterun\caml\s.h
copy config\Makefile.msvc64 config\Makefile
# Setting the cygwin path first and then VS is important to avoid the clash
# on the link tool
cmd.exe /c --% "SET PATH=C:\tools\cygwin\bin;%PATH% & "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"" -arch=amd64 & make -f Makefile.nt flexdll world bootstrap opt opt.opt install
cd ..
Remove-Item ocaml -Force -Recurse
config.vm.provision :shell, inline: $ocaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment