Does Ocaml OPAM detect previously installed Ocaml packages?

I recently installed OPAM as instructed to try, and it looks beautiful and I would like to use it. However, it does not detect previously installed OCAML packages, which I installed manually before I decided to try OPAM.

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

I am afraid to do anything because I have no idea what effect he could have set for another package. OPAM will overwrite or reinstall ocamlfind at least. Will this clobber be my existing ocamlfind and its knowledge of all the packages that I have already installed manually and my ability to use them? I do not want to redo everything again and again. I searched and searched, but can’t find any documentation or forum posts about this exact topic, and I don’t know exactly how ocamlfind works under the hood.

At least it would be nice if OPAM could either detect or say which packages already exist and where they are in order to avoid unnecessary recompilation. It may already be doing this, but I could not find out if that is the case.

+6
source share
1 answer

OPAM provides one (or more) OCaml installations that are independent of the default by default, that is, a compiler or libraries typically located in /usr/bin , /usr/lib/ocaml or /usr/local/blahblah . Thus, your manually installed OCaml system based on OPAM can coexist. All OPAM installation is done under $HOME/.opam/switch/ (default = switch = system), including the executable. So, for your case, OCamlFind has not been overwritten by OPAM. OPAM installed another OCamlFind in a different directory.

Which system can be "switched" using environment variables. "opam config env" shows the variables you must declare in order to use the current "switch". If you want to use the default setting, make sure that these variables do not reference OPAM stuff.

To live with your compiled libraries and OPAM packages, recompile them and reinstall them in a switched OPAM environment. Please note that OPAM may overwrite your packages here. For example, if you install ocamlfind manually in the "system" OPAM dir, then if you type "opam install ocamlfind", OPAM will overwrite your OCamlFind installation. (Oh, BTW, I think OPAM warns us when it overwrites an existing installation here, because the OPAM package has no information about which OCamlFind packages it installs).

Using libraries installed in the default location and OPAM packages at the same time ... AFAIK, is not easy. I think at least OPAM is not intended for such use. To avoid confusing library paths, put them in one of the OPAM switches.

If you have any OPAM suggestions in the future, post them at https://github.com/OCamlPro/opam .

+6
source

Source: https://habr.com/ru/post/945900/


All Articles