Camomile runtime path configuration


I’m writing a REPL based on Lambda-term’s example Lambda-term uses Zed which uses Camomile - this makes me an indirect user of Camomile. My OCaml version is 4.10.0, all libraries are installed via OPAM in their most recent versions on Debian stable.

Camomile needs some data file locations at runtime. It provides a module called CamomileLibraryDefault which contains a preconfigured Camomile module using some paths determined at compilation time.

When I run my binary on the machine I used to compile it, everything works like expected. But the binary won’t work on machines without an OPAM installation in the same path:

% ./mybinary
Fatal error: exception Not_found
Raised at file "Camomile/internal/", line 50, characters 52-67
Called from file "Camomile/internal/" (inlined), line 187, characters 4-48
Called from file "Camomile/public/", line 376, characters 16-46
Called from file "src/", line 816, characters 13-53

The binary uses the paths determined at compile time:

% strace ./mybinary 2>&1 | grep mar
openat(AT_FDCWD, "/home/ap/.opam/4.10.0/share/camomile/database/White_Space.mar", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/home/ap/.opam/4.10.0/share/camomile/database/Alphabetic.mar", O_RDONLY|O_CLOEXEC) = 4

So Camomile is using a path based on the OPAM variable %{share}% in camomile.opam.
I would like to get a different path, based on /usr/local/share (for example).

If I were a direct user of Camomile, this would be easy - Camomile provides functors to create configured Camomile modules. But I’m an indirect user of Camomile. Lambda-term’s code uses Zed_string which takes it’s Camomile module from the preconfigured CamomileLibraryDefault - s.

I think I have two options:

  1. Compiling camomile, zed and lambda-term outside of OPAM to control what goes into CamomileLibraryDefault.Camomile


  1. Somehow modifying or exchanging CamomileLibraryDefault.Camomile at runtime (how?).

What is the best way to do this? It’s very possible I’m missing something extremely basic here.

Thank you!

1 Like

maybe ask zed people to expose interface which allows configuring camomile (by optionally passing config module)?

Lambda-term also uses open CamomileLibraryDefault.Camomile (e.g. in I’m still hoping there’s a solution without having to bother two software projects.

1 Like

camomile previously had a mode that allowed configuring with environment variables, but it was removed, I don’t know why. Looks like it could have been a solution here