Search code examples
macosocamlopam

Install opam in Mac OS


I want to install opam in Mac OS X EL Capitan 10.11.1, but I got the following error:

Pro:~ $ brew install opam
Error: You must `brew link ocaml' before opam can be installed
Pro:~ $ brew link ocaml
Linking /usr/local/Cellar/ocaml/4.02.3... 
Error: Could not symlink lib/ocaml/Makefile.config
/usr/local/lib/ocaml is not writable.

Could anyone help?

PS: I think my OCaml installation is totally a mess under my Mac OS. How can I remove OCaml completely before doing anything?

Edit 1:

So with the help of John and Daniel, I first solved the permission problem, then brew update, then brew remove ocaml, then brew install opam.


Solution

  • According to the error message it seems that you have a permission problem in your brew install. You should do something like:

    sudo chown -R "$USER":admin /usr/local /Library/Caches/Homebrew