ocamlduneppx

Why can't dune recognize ppx_jane?


I am now writing a project in OCaml v4.06, and I have installed ppx_jane v0.11.0. Actually the environment is based on a docker image. Now here is the dune file

(menhir 
 (modules parser))

(ocamllex lexer)

(executable
 (name compiler)
 (libraries core)
 (preprocess (pps ppx_jane)))

Which I think is pretty simple, but running dune build compiler.exe will output

File "dune", line 9, characters 18-26:
9 |  (preprocess (pps ppx_jane)))
                      ^^^^^^^^
Error: Ppx dependency on a non-ppx library "ppx_jane". If "ppx_jane" is in
fact a ppx rewriter library, it should have (kind ppx_rewriter) in its dune
file.
-> required by _build/default/compiler.exe

How could I fix this?

For now I am using corebuild -use-ocamlfind -use-menhir and it works well. So I think the ppx_jane should be okay to work in this environment. Furthermore, the reason why I am turning to dune is that with these bare files, VSCode works badly to give any useful information. It just shows unbound module everywhere. Any suggestion to improve this is also appreciated.


Solution

  • The version v0.11.0 of ppx_jane was released when dune was still an experimental build system called jbuilder. The package simply lacks the metadata necessary to be used as a ppx by dune.

    The simpler solution is probably to upgrade to more recent versions of OCaml, dune and ppx_jane.