opam-repository
opam-repository copied to clipboard
Issue with `libcamlp-streams-ocaml` and conflicting library paths after installing via `ledit` and OPAM switch
In the latest Ubuntu 25.04 beta, after installing the ledit package (which depends on OPAM > OCaml > OCaml-interp > ledit), libcamlp-streams-ocaml is placed in /usr/lib/x86_64-linux-gnu-ocaml/5.3.0/camlp-streams but lacks the necessary .cmi files, causing issues when using the Stream module.
The problem arises after installing an Ocaml switch that is matching the system version (in this case, 5.3.0). When attempting to install camlp5 OPAM package which depends on not-ocamlfind, the installation of not-ocamlfind fails because it cannot find the Stream module. Specifically, when adding only the camlp-stream package along with ocamlfind we see that the ~/.opam/5.3.0/lib/findlib.conf file contains two library paths: one in the system directory and another in the OPAM switch directory:
path="/usr/lib/x86_64-linux-gnu/ocaml/5.3.0:/home/a2/.opam/5.3.0/lib"
As a result, ocamlfind searches the system directory and the system version of libcamlp-streams, installed for ledit, is incomplete (lacking the necessary libcamlp-streams-ocaml-dev files). Consequently, compiling not-ocamlfind fails due to missing development files.
The real issue lies in the order of the search paths in findlib.conf, which causes the incomplete system version of camlp-streams to be used first. The solution is to adjust the path order so that the OPAM switch directory is searched before the system directory, which would avoid conflicts and ensure the correct version is used.
This is issue is not in opam (the tool) so i moved it to opam-repository (the package repository).
For what it's worth, the next version of opam (the tool) will not use ocaml-system by default (see https://github.com/ocaml/opam/pull/6307) so this shouldn't be a problem unless you specifically asks for that package. This will be part of the upcoming opam 2.4 whose first alpha is due in a week.
In any case thanks for the investigation, this should definitely be fixed in the ocamlfind package.
The order was at least done that way on purpose (cf. https://github.com/ocaml/ocamlfind/pull/52) so that the opam switch's site-lib can never override the compiler's own META files (that said, system switches are notoriously hairy).
I rather think this is an Ubuntu packaging bug - the files just can't be separated this way. I can see that it's trying to put the dynlink plugins in libcamlp-streams-ocaml (and so including the META) and then the rest of it in libcamlp-streams-ocaml, but OCaml just doesn't work that way. apt install libcamlp-streams ocaml-findlib results in a similarly broken system-installed ocamlfind (you can't use the package in the toplevel either).