I get the following error when playing in the Toplevel (Emacs) with ppx_deriving_yojson (Yojson alone works well):
#require "yojson";;
#require "ppx_deriving_yojson";;
type foo = { bar : string; } [@@deriving yojson]
Error: Reference to undefined global `Ppx_deriving_yojson_runtime'
I’ve read:
https://github.com/ocaml-ppx/ppx_deriving_yojson
Add ppx_deriving.runtime to requires in META (#47)
and also the following that explains ppx_deriving_yojson.runtime package must be added.
Error: Required module `Ppx_deriving_yojson_runtime' is unavailable
So I tried to load this runtime package with the following directive:
#require "ppx_deriving_json.runtime";;
(* no visible effect added path or loaded module *)
and I still have the same error.
Can you give a hint about what is wrong?
Thanks.
EDIT
I confirm I can generate the yojson helpers functions from the ocaml CLI:
$ ocaml
# #require "yojson";;
# #require "ppx_deriving_yojson";;
# type foo = { bar : string; } [@@deriving yojson]
type foo = { bar : string; }
val foo_to_yojson : foo -> Yojson.Safe.t = <fun>
val foo_of_yojson : Yojson.Safe.t -> foo Ppx_deriving_yojson_runtime.error_or =
<fun>
val _ : Yojson.Safe.t -> foo Ppx_deriving_yojson_runtime.error_or = <fun>
but not from the Toplevel within Emacs.
So it looks like there is no problem with ocaml and ppx_deriving_yojson but more with the Emacs Toplevel.
Any idea ?