Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Ocaml OPAM detect prior installed Ocaml packages?

I recently installed OPAM as per instructions to give it a try and it looks nice and I'd like to use it. However, it fails to detect previously installed OCAML packages that I installed manually before I choose to give OPAM a try.

The first thing OPAM wants to do for any package installation now is to install ocamlfind. Querying for info about packages I installed manually do not reflect that they are already installed. This includes ocamlfind.

I'm afraid to do anything as I have no idea what effect it might have to install another package. OPAM will overwrite or reinstall ocamlfind at the very least. Would this clobber my existing ocamlfind and its knowledge of all the packages I already manually installed and my ability to use them? I don't want to have to reinstall everything all over again. I've searched and searched but cannot find any documentation or forum posts about this precise topic and I don't know exactly how ocamlfind works under the hood.

At the very least it would be nice if OPAM could either detect, or be told, which packages already exist and where they reside to avoid needless recompilation. Maybe it already does this but I've not been able to discover if it does.

like image 527
paul Avatar asked May 27 '13 00:05

paul


1 Answers

OPAM provides one (or more) OCaml installations independent from the default one, i.e. the compiler or libraries normally found in /usr/bin, /usr/lib/ocaml or /usr/local/blahblah. Therefore, your OCaml system installed by hand and OPAM based one can co-exist. All the OPAM installation is done under $HOME/.opam/switch/ (switch=system by default), including the binary executable. So, for your case, OCamlFind was not overwritten by OPAM. OPAM has installed another OCamlFind in a different directory.

Which system is used can be "switched" by environmnetal variables. "opam config env" shows the variables you must declare to use the current "switch". If you want to use the default installation, make sure that these variables not refer OPAM things.

To live with your hand compiled libraries and OPAM packages, recompile and reinstall them under the OPAM switched environment. Note that OPAM may overwrite your packages here. For example, if you install ocamlfind by hand in "system" OPAM dir then if you type "opam install ocamlfind", then OPAM overwrites your OCamlFind installation. (Oh, BTW, I think it is hard for OPAM to warn us when it is overwriting existing installation here, since an OPAM package has no information about which OCamlFind packages it installs).

Using the libraries installed in the default place and OPAM packages at the same time is... AFAIK, not easy. At least OPAM is not desgined for such use, I think. To avoid confusion of library paths, port them to one of OPAM switch.

If you get some feature wishes of OPAM in future, post them at https://github.com/OCamlPro/opam.

like image 69
camlspotter Avatar answered Oct 19 '22 08:10

camlspotter