Is it currently possible to use ppx_deriving in a jbuilder project

Getting this trying to get a hello world to build.

$ dune exec hello/main.exe
File "hello/dune", line 5, characters 2-20:
5 |   (pps ppx_deriving)))
      ^^^^^^^^^^^^^^^^^^
Error: No ppx driver were found. It seems that ppx_deriving is not compatible
with Dune. Examples of ppx rewriters that are compatible with Dune are ones
using ocaml-migrate-parsetree, ppxlib or ppx_driver.
$ opam show ppx_deriving

<><> ppx_deriving: information on all versions ><><><><><><><><><><><><><><>  🐫
name                   ppx_deriving
all-installed-versions 4.2.1 [ocaml-system.4.07.1]
all-versions           0.1  0.2  0.3  1.0  1.1  2.0  2.1  2.2  3.0  3.1  3.2  3.3  4.0  4.1  4.1.5  4.2  4.2.1

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><>  🐫
version       4.2.1
repository    default
url.src:      "https://github.com/ocaml-ppx/ppx_deriving/archive/v4.2.1.tar.gz"
url.checksum: "md5=2195fccf2a527c3ff9ec5b4e36e2f0a8"
homepage:     "https://github.com/whitequark/ppx_deriving"
bug-reports:  "https://github.com/whitequark/ppx_deriving/issues"
dev-repo:     "git+https://github.com/whitequark/ppx_deriving.git"
authors:      "whitequark <whitequark@whitequark.org>"
maintainer:   "whitequark <whitequark@whitequark.org>"
license:      "MIT"
tags:         "syntax"
depends:      "ocaml" {> "4.03.0"}
              "ocamlbuild" {build}
              "ocamlfind" {build & >= "1.6.0"}
              "cppo" {build}
              "cppo_ocamlbuild" {build}
              "ocaml-migrate-parsetree"
              "ppx_derivers"
              "ppx_tools" {>= "4.02.3"}
              "result"
              "ounit" {with-test}
synopsis      Type-driven code generation for OCaml >=4.02
description   ppx_deriving provides common infrastructure for generating
              code based on type definitions, and a set of useful plugins
              for common tasks.
$ ocaml --version
The OCaml toplevel, version 4.07.1

I have tried opam reinstall ocaml-migrate-parsetree

It doesn’t seem to have helped.

Does (pps ppx_deriving.std) work? The installation is a bit different than dune-based ppxs, so this is a bit difficult to discover.

Yes indeed, it does work! But how did you know make this change?
I also don’t understand the part about “The installation is a bit different than dune-based ppxs”.
(fyi, I’m was trying: https://dune.readthedocs.io/en/latest/usage.html)

For most packages, (pps packagename) is the right solution and will work out of the box. For various historical reasons, that is not the case with ppx_deriving. It is installed using a layout that existed before more modern conventions emerged.

But how did you know make this change?

If you want more details, ppx_deriving is a library used to define ppx_deriving plugins, individual rewriters are available as ppx_deriving.eq, etc, and they are all linked into a ppx_deriving.std super-rewriter. You can find that info in $(ocamlfind query ppx_deriving)/META, but I wouldn’t bother learning how to do that in 2019 - that case will mostly apply to ppx_deriving these days.

1 Like

It is notable that ppx_deriving opam package points to the wrong homepage, bugreports page, and development repository.