How to install a specific version of OCaml on MacOS? I am trying to install version 4.02.3 of OCaml on MacOS 10.14.6 with the following command
brew install ocaml@4.02.3

but I get an error
Error: No available formula with the name &quot;ocaml@4.02.3&quot;

I need that specific version to compile unison with that specific version, so I can use unison between a Linux box (where I cannot install a different version of ocaml and the Mac).
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