Camomile runtime path configuration

Hi!

I’m writing a REPL based on Lambda-term’s example repl.ml. 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/database.ml", line 50, characters 52-67
Called from file "Camomile/internal/unidata.ml" (inlined), line 187, characters 4-48
Called from file "Camomile/public/uCharInfo.ml", line 376, characters 16-46
Called from file "src/zed_utf8.ml", 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. zed_string.ml.

I think I have two options:

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

or

  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 lTerm_read_line.ml). 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