ocaml-templates / spin-jsoo-react

Spin project template for React application with Js_of_ocaml
11 stars 2 forks source link

gen_js_api fails to build during install #5

Open glennsl opened 2 years ago

glennsl commented 2 years ago

This fails during spin new with error:

🎁  Installing packages. This might take a couple minutes.
spin: [ERROR] The template generation failed:
The command make dev did not run successfully: exited with code 2

Running make dev yields:

[ERROR] The compilation of gen_js_api.1.0.6 failed at "dune build -p gen_js_api -j 4".

#=== ERROR while compiling gen_js_api.1.0.6 ===================================#
# context     2.1.1 | linux/x86_64 | ocaml-system.4.13.1 | pinned(git+https://github.com/jchavarri/gen_js_api.git#typ_var#1e629a51)
# path        ~/.opam/4.13.1/.opam-switch/build/gen_js_api.1.0.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p gen_js_api -j 4
# exit-code   1
# env-file    ~/.opam/log/gen_js_api-2334477-4a6bad.env
# output-file ~/.opam/log/gen_js_api-2334477-4a6bad.out
### output ###
#       ocamlc ppx-lib/.gen_js_api_ppx.objs/byte/gen_js_api_ppx.{cmi,cmti} (exit 2)
# (cd _build/default && /usr/bin/ocamlc.opt -w -40 -g -bin-annot -I ppx-lib/.gen_js_api_ppx.objs/byte -I /home/glennsl/.opam/4.13.1/lib/ocaml-migrate-parsetree -I /usr/lib/ocaml/compiler-libs -no-alias-deps -o ppx-lib/.gen_js_api_ppx.objs/byte/gen_js_api_ppx.cmi -c -intf ppx-lib/gen_js_api_ppx.mli)
# File "ppx-lib/gen_js_api_ppx.mli", line 9, characters 13-56:
# 9 | val mapper : Migrate_parsetree.Ast_408.Ast_mapper.mapper
#                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound module Migrate_parsetree.Ast_408.Ast_mapper

Looking at the Makefile suggests this was made for OCaml 4.10, but switching to that yields the same error:

[ERROR] The compilation of gen_js_api.1.0.6 failed at "dune build -p gen_js_api -j 4".

#=== ERROR while compiling gen_js_api.1.0.6 ===================================#
# context     2.1.1 | linux/x86_64 | ocaml-base-compiler.4.10.2 | pinned(git+https://github.com/jchavarri/gen_js_api.git#typ_var#1e629a51)
# path        ~/.opam/4.10.2/.opam-switch/build/gen_js_api.1.0.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p gen_js_api -j 4
# exit-code   1
# env-file    ~/.opam/log/gen_js_api-2336308-3e08ae.env
# output-file ~/.opam/log/gen_js_api-2336308-3e08ae.out
### output ###
#       ocamlc ppx-lib/.gen_js_api_ppx.objs/byte/gen_js_api_ppx.{cmi,cmti} (exit 2)
# (cd _build/default && /home/glennsl/.opam/4.10.2/bin/ocamlc.opt -w -40 -g -bin-annot -I ppx-lib/.gen_js_api_ppx.objs/byte -I /home/glennsl/.opam/4.10.2/lib/ocaml-migrate-parsetree -I /home/glennsl/.opam/4.10.2/lib/ocaml/compiler-libs -no-alias-deps -o ppx-lib/.gen_js_api_ppx.objs/byte/gen_js_api_ppx.cmi -c -intf ppx-lib/gen_js_api_ppx.mli)
# File "ppx-lib/gen_js_api_ppx.mli", line 9, characters 13-56:
# 9 | val mapper : Migrate_parsetree.Ast_408.Ast_mapper.mapper
#                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound module Migrate_parsetree.Ast_408.Ast_mapper

cc @jchavarri as this is what jsoo-react suggests for getting started.

jchavarri commented 2 years ago

Hm sorry about this, I have not updated this template for some time. I will try to take a look soon.

In the meantime, as a workaround I can suggest checking https://github.com/ml-in-barcelona/jsoo-react-template, which does not have the convenience of this spin template, but has been updated quite recently.

glennsl commented 2 years ago

Thanks, will give that a shot!

Also, if it helps, it fails with 4.08 too, but with a slightly different error:

#=== ERROR while compiling gen_js_api.1.0.6 ===================================#
# context     2.1.1 | linux/x86_64 | ocaml-base-compiler.4.08.1 | pinned(git+https://github.com/jchavarri/gen_js_api.git#typ_var#1e629a51)
# path        ~/.opam/4.08.1/.opam-switch/build/gen_js_api.1.0.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p gen_js_api -j 4
# exit-code   1
# env-file    ~/.opam/log/gen_js_api-2355154-c3b56c.env
# output-file ~/.opam/log/gen_js_api-2355154-c3b56c.out
### output ###
#       ocamlc ppx-driver/.gen_js_api_ppx_driver.objs/byte/gen_js_api_ppx_driver.{cmi,cmo,cmt} (exit 2)
# (cd _build/default && /home/glennsl/.opam/4.08.1/bin/ocamlc.opt -w -40 -g -bin-annot -I ppx-driver/.gen_js_api_ppx_driver.objs/byte -I /home/glennsl/.opam/4.08.1/lib/base -I /home/glennsl/.opam/4.08.1/lib/base/base_internalhash_types -I /home/glennsl/.opam/4.08.1/lib/base/caml -I /home/glennsl/.opam/4.08.1/lib/base/shadow_stdlib -I /home/glennsl/.opam/4.08.1/lib/ocaml-compiler-libs/common -I [...]
# File "ppx-driver/gen_js_api_ppx_driver.ml", line 22, characters 4-39:
# 22 |     Ppxlib.Driver.enable_location_check ()
#          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: Unbound value Ppxlib.Driver.enable_location_check
jchavarri commented 2 years ago

I checked the template and it seems it was created at a time where we had to pin gen_js_api to a custom fork.

That's not the case anymore, as jsoo-react uses the published version of gen_js_api. So I don't think we need to pin gen_js_api like the spin template is doing here:

https://github.com/ocaml-templates/spin-jsoo-react/blob/74b44e607fb6052997b5b4458c5355e1ddae6b59/template/Makefile#L41