I am using docker to build an ubuntu binary. It has been working reasonably well. But recently I started using “Uuid” module from “Core”. With this, I get “Unbound module Uuid” error. Same code compiles on my laptop MacOSX. Any thoughts about what might be going wrong? Some additional details follow.
Error message:
File "pervasives/utils.ml", line 95, characters 13-27:
95 | let uuid = Uuid.to_string (Uuid.create ()) in
^^^^^^^^^^^^^^
Error: Unbound module Uuid
My Dockerfile looks like this
FROM ocaml/opam2:centos
RUN opam switch 4.08
RUN eval $(opam env)
# RUN opam install -y core ocamlbuild.0.12.0 getopt menhir re2
RUN opam install -y core ocamlbuild ocamlnet getopt menhir re2
ADD build.sh .
CMD ["./build.sh"]
Local (Mac OSX) settings
$ ocaml --version
ocaml --version
The OCaml toplevel, version 4.07.1
$ opam --version
opam --version
2.0.1
Uuid got split out into a separate library between those versions of Core. You need to add core.uuid to your dune file libraries field. Also, the module is now called Uuid_unix.
Yes, I think you can just add the core.uuid package.
I am aware it’s a versioning issue. For core starting at version v0.12.0, you’ll have to add the package explicitly to get the UUID library—this isn’t a workaround, it’s the intended behavior.