Error when calling my ppx rewriter on my example code

I build up the ppx rewriter and compiled it using

ocamlbuild -use-ocamlfind my_ppx.native

Then when I am calling this my_ppx.native on my code to produce the transformed code where is the original file and I am trying to produce the transformed code of it.

ocamlfind ocamlc -ppx my_ppx.native -o example.out -package ezjsonm,irmin-unix,lwt.unix -package ppx_sexp_conv -package ppx_bin_prot -package ocaml-migrate-parsetree.driver-main -linkpkg

I get this error:
Error while running external preprocessor

Command line: my_ppx.native ‘/var/folders/z3/4f0t350x0p19n87dxrqw7q5w0000gn/T/camlppx775b61’ ‘/var/folders/z3/4f0t350x0p19n87dxrqw7q5w0000gn/T/camlppxbe4b5c’

I could not understand how to get rid of this error.

I am using

Ocaml 4.05.0

ppx_tools 5.0+4.05.0

Mac OS High Sierra

Your ppx rewriter is raising an error when called by the compiler. The error is probably in your ppx code. You may also want to try a simpler example for your test, one that does not require so mny external libraries.

This is a built-in extension node (as indicated by the ocaml prefix)

[%%ocaml.error "Fail here"]

which can be used to signal a ppx error to the compiler.

I tried to run my rewriter using the flag -dsource, which produces the same kind of error. Is there really a problem with my ppx code because I am able to build the native code of the ppx file successfully? How to debug the errors in the ppx code because during building the native code of it, it produces no error?

[%%ocaml.error ;;"[dalify]: Unavailable dalify-ing type."


File “none”, line 1:

Error: [dalify]: Unavailable dalify-ing type.

Your code can perfectly compile fine and have higher-level errors. It is hard to tell from the available information.
You could test on a marshalled ast and check that yourppx input output outputs correctly a marshalled ast on output.

Just for clarification:
I am using ocamlfind to run my ppx_rewriter on my code to produce the transformed code. Something like this
ocamlfind ppx_tools/ppx_rewriter my_ppx.native

where my_ppx.native is build using
ocamlbuild -use-ocamlfind my_ppx.native

sh: 1 : my_ppx.native: not found
which is followed by
Error: Error while running external preprocessor.

My question: Is it the case that ocamlfind is not able to find .native so there is the error?Could anyone elaborate the bold portion of the error. I could not understand why my_ppx.native is not found in sh.

You want to use ocamlfind ppx_tools/ppx_rewriter ./my_ppx.native (with a ./ prefix) since the current directory is not in PATH by default .

Thanks for your help. I was able to run my ppx rewriter on my example code. But I have several questions:
(1) So my rewriter works fine for ocaml 4.02.3 version and ppx_deriving 4.1, ppx_blob 0.2, ppx_core 113.33.03, ppx_driver 113.33.04, ppx_tools 5.0+4.02.0 .
I am able to compile my ppx code as well call my rewriter on the example code and I get the desired transformed code.
(2) Now the question is: I am trying to work for the same project using OCaml 4.07.1. As we all know there has been changes in the Parsetree.mli file between both the version 4.02.3 and 4.07.1. Hence I changed my ppx rewriter code accordingly so that my code compiles with the OCaml 4.07.1 version. I changed my code to make it compatible with OCaml 4.07.1. So my ppx code compiles with OCaml 4.07.1, ppx_driver v0.11.0, ppx_tools 5.1+4.06.0, ppx_deriving 4.2.1, ppx_blob 0.4.0.
I am able to produce .native for my ppx rewriter using the command
ocamlbuild -use-ocamlfind my_ppx.native
(3) Now when I am calling my rewriter on the example code:
ocamlfind ppx_tools/rewriter ./my_ppx.native
This always produce the transformed .ml file with only [%%ocaml.error…]
What might be the reason for it? My is same that I used for the other OCaml version. I corrected the type mismatch error between both the versions.
Any feedback about what exactly is happening and where should I focus to get rid of the error.

Never mind. I solved the problem.