Question regarding which package to include



Hello, I’m having a weird error here. I made a little project using Opium and worked on it last week. I’m using jbuilder for the build system. I had the following on my jbuild file:

(jbuild_version 1)

(library (
  (name lib)
  (libraries (opium.unix))))

and all was fine and well. But today I tried to compile it again, and it complains about missing opium.unix library, eventhough I have opium installed:

$ opam list --installed-root
# Installed packages for 4.04.2-opium:
base-bigarray    base  Bigarray library distributed with the OCaml compiler
base-threads     base  Threads library distributed with the OCaml compiler
base-unix        base  Unix library distributed with the OCaml compiler
core           v0.9.1  Industrial strength alternative to OCaml's standard library
ocp-indent      1.6.0  A simple tool to indent OCaml programs
opium          0.16.0  Sinatra like web toolkit based on Lwt + Cohttp
ounit           2.0.0  Unit testing framework loosely based on HUnit. It is similar to JUnit, and other XUnit testing frameworks
utop            2.0.1  Universal toplevel for OCaml

$ make build
jbuilder build @install
Error: External library "opium.unix" not found.
-> required by "lib/jbuild (context default)"
Hint: try: jbuilder external-lib-deps --missing @install
make: *** [build] Error 1

$ jbuilder external-lib-deps --missing @install
Error: The following libraries are missing in the default context:
- opium.unix
Hint: try: opam install opium

For the sake of trying, I changed the definition in the previous jbuild to use opium instead of opium.unix, and the compilation succeeds! Which I find weird because in Opium’s readme, it tells me to use opium.unix.

One change that I remember making was upgrading versions of packages, notably jbuilder from 1.0+beta10 to 1.0+beta11. What could possibly cause this error?


If you’re using opium 0.16.0 (recently released), there has been a slight re-org of findlib/packages that will hopefully make the situation more consistent. There are now 2 opam packages: opium and opium_kernel with equivalent findlib names. In your project, you should use opium which is the new name for opium.unix.


Ah, yes, I do use opium 0.16.0, but I wasn’t sure which version I used before so I didn’t include that info.

Hmm, so in any given library, is there a way for me to determine what I should use for findlib packages?


There’s no way that works in general. You must inspect individual opam packages and see which findlib packages are provided through META, _oasis files, etc. You can also just list all your findlib packages $ ocamlfind list and guess from there.

By the way, this issue is the motivation why I simply renamed the findlib packages in opium (and elsewhere) to simple match the opam package names. This is also what jbuilder pretty much focuses its users to do, so if you stick to well behaved packages you aren’t as likely to run into this problem.


I see. Looks like I still need to delve further into opam packaging :slight_smile:

Thanks for the explanation, @rgrinberg!