This week I was trying to write a ppx in ocaml use it in my reasonml project but I was getting an error about mismatching Ocaml versions.
Ast_mapper: OCaml version mismatch or malformed input
When I checked my versions sure enough there was a mismatch:
> bsc BuckleScript 4.0.0 (Using OCaml4.02.3+BS ) > ocaml -version The OCaml toplevel, version 4.07
Reasonml and Bucklescript use an older version of ocaml, version 4.02.3. I had compiled my ppx binary however with 4.07.
Fortunately it is rather easy to switch ocaml versions using
opam, the Ocaml package manager. If you have opam installed (on mac
brew install opam) then you can use the
opam switch 4.02.3
opam switch without an argument will show you all the available versions.