How to install a specific version of OCaml on MacOS?
Solution 1:
You can use the git history to obtain the formula for OCaml 4.02.3
Go to the local directory where formulas are stored:
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
Look at the history of the OCaml formula:
git log ocaml.rb
It appears that the last commit of version 4.02.3 is commit 3cdad82334496ca9fe8d8fb37
.
Check out this commit:
git checkout 3cdad82334496ca9fe8d8fb37
By default, Homebrew make an update before an install, so you have to specify to not update before the install:
HOMEBREW_NO_AUTO_UPDATE=1 brew install ocaml
Check that you have the right version with:
ocaml -version
When finished, don't forget to go back to the master branch, in the /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
directory:
git checkout master