Need help compiling incr_dom examples

Hey folks, I'm trying to run the examples from the Jane Street incr_dom package and I'm not having any luck. I have to say I haven't used OCaml in maybe 15 years now, so I'm not familiar with the new build tooling (opam, jbuilder/dune and friends) so I'm probably doing something silly. Thanks for your help.

Short version of the error:
File "src/", line 2, characters 14-30:
Error: Unbound module Incremental

Long version and setup:
Linux Ubuntu VM, installed from scratch today, opam installed from apt, ocaml installed
$ ocamlc -v
The OCaml compiler, version 4.05.0
Standard library directory: /usr/lib/ocaml
$ opam list | grep incr
incr_dom                    v0.11.0  A library for building dynamic webapps, usi
incr_map                    v0.11.0  Helpers for incremental operations on map l
incr_select                 v0.11.0  Handling of large set of incremental output
incremental                 v0.11.0  Library for incremental computations
incremental_kernel          v0.11.1  Library for incremental computations depend
~/src/incr_dom$ dune build example/incr_decr/{main.bc.js,index.html}
      ocamlc src/.incr_dom.objs/incr_dom__Incr.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /usr/bin/ocamlc.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I src/.incr_dom.objs -I src/.incr_dom.objs/.private -I /home/francois/.opam/system/lib/async_js -I /home/francois/.opam/system/lib/async_kernel -I /home/francois/.opam/system/lib/async_rpc_kernel -I /home/francois/.opam/system/lib/base -I /home/francois/.opam/system/lib/base/caml -I /home/francois/.opam/system/lib/base/md5 -I /home/francois/.opam/system/lib/base/shadow_stdlib -I /home/francois/.opam/system/lib/bin_prot -I /home/francois/.opam/system/lib/bin_prot/shape -I /home/francois/.opam/system/lib/bytes -I /home/francois/.opam/system/lib/core -I /home/francois/.opam/system/lib/core_kernel -I /home/francois/.opam/system/lib/core_kernel/base_for_tests -I /home/francois/.opam/system/lib/fieldslib -I /home/francois/.opam/system/lib/incr_map -I /home/francois/.opam/system/lib/incr_select -I /home/francois/.opam/system/lib/incremental -I /home/francois/.opam/system/lib/incremental_kernel -I /home/francois/.opam/system/lib/jane-street-headers -I /home/francois/.opam/system/lib/js_of_ocaml -I /home/francois/.opam/system/lib/parsexp -I /home/francois/.opam/system/lib/ppx_assert/runtime-lib -I /home/francois/.opam/system/lib/ppx_bench/runtime-lib -I /home/francois/.opam/system/lib/ppx_compare/runtime-lib -I /home/francois/.opam/system/lib/ppx_expect/collector -I /home/francois/.opam/system/lib/ppx_expect/common -I /home/francois/.opam/system/lib/ppx_expect/config -I /home/francois/.opam/system/lib/ppx_hash/runtime-lib -I /home/francois/.opam/system/lib/ppx_inline_test/config -I /home/francois/.opam/system/lib/ppx_inline_test/runtime-lib -I /home/francois/.opam/system/lib/ppx_sexp_conv/runtime-lib -I /home/francois/.opam/system/lib/protocol_version_header -I /home/francois/.opam/system/lib/re -I /home/francois/.opam/system/lib/re/posix -I /home/francois/.opam/system/lib/seq -I /home/francois/.opam/system/lib/sexplib -I /home/francois/.opam/system/lib/sexplib/unix -I /home/francois/.opam/system/lib/sexplib0 -I /home/francois/.opam/system/lib/spawn -I /home/francois/.opam/system/lib/splittable_random -I /home/francois/.opam/system/lib/stdio -I /home/francois/.opam/system/lib/stringext -I /home/francois/.opam/system/lib/typerep -I /home/francois/.opam/system/lib/tyxml -I /home/francois/.opam/system/lib/uchar -I /home/francois/.opam/system/lib/uri -I /home/francois/.opam/system/lib/uutf -I /home/francois/.opam/system/lib/variantslib -I /home/francois/.opam/system/lib/virtual_dom -I /usr/lib/ocaml/threads -no-alias-deps -opaque -open Incr_dom__ -o src/.incr_dom.objs/incr_dom__Incr.cmo -c -impl src/
File "src/", line 2, characters 14-30:
Error: Unbound module Incremental
1 Like

I would guess you need to add incremental to the libraries section of your dune file?

In general I suggest against using the system switch and recommend using local switches. In my experience system switches have been quite flaky overall.

If you’re using the examples from the tip of the repo and incr_dom from opam, nothing’s going to work. You should make sure to get the examples from the same version. The APIs have been cleaned up and simplified fairly significantly recently, which may be the source of your issues.



As @Yaron_Minsky said, the current master is pointing to an un-released version of incr_dom.

The following commit should point to a state that compiles with the current official release.

Thanks for the clues. I ended up creating a new opam switch with 4.0.7, reinstalling all incr* packages. Most examples compile. I’ll try compiling from consistent versions without the opam packages for the remainder of the examples.

The API cleanup Yaron mentioned above is quite significant and worth to check out. It seems that you already have an opam switch dedicated to exploring incr_dom so you might as well modify it to use the latest changes available on github:

opam repo add janestreet-dev
opam update
opam upgrade

With this setup you should be able to build the incr_dom examples from the master branch. Beware that this might break other packages relying on released versions of janestreet packages. I personally use a local opam switch for my incr_dom project to avoid interference.

1 Like