fxfactorial / ethereum-re

Access the ethereum network with pure ReasonML, use with native code or with type safe JavaScript
20 stars 1 forks source link

native build problem #2

Closed rsaccon closed 6 years ago

rsaccon commented 6 years ago

I never did any native reason or ocaml stuff, so after successfully building the JS version, my attempt to build the native version did not look good:

robertos-mbp:ethereum-re robertosaccon$ ./node_modules/.bin/bsb -make-world -backend native
ninja: no work to do.
ninja: Entering directory `lib/bs/native'
[1/6] Building src/types.cmx
FAILED: src/types.cmx src/types.cmi 
ocamlfind ocamlopt   -I /Users/robertosaccon/ethereum-re/node_modules/rex-json/lib/ocaml/native -I src/native-code -I src/js-code -I src/__test_native__ -I src/__test_js__ -I src  -package lwt.unix -package cohttp.lwt -package result -package ppx_deriving.show -package ppx_deriving.std -thread -passopt -no-alias-deps -passopt -color -passopt always -o src/types.cmx -w -30-40+6+7+27+32..39+44+45+101-40+6+7-26-27+32..39-28-44+45 -warn-error +8 -g -c -intf-suffix .mliast_simple -impl src/types.mlast_simple 
ocamlfind: Package `cohttp.lwt' not found
ninja: build stopped: subcommand failed.
robertos-mbp:ethereum-re robertosaccon$ 
robertos-mbp:ethereum-re robertosaccon$ 
robertos-mbp:ethereum-re robertosaccon$ 
robertos-mbp:ethereum-re robertosaccon$ 
robertos-mbp:ethereum-re robertosaccon$ opam install cohttp lwt js_of_ocaml
The following actions will be performed:
  - install stringext       1.5.0                       [required by cohttp]
  - install js-build-tools  113.33.04                   [required by fieldslib, ppx_fields_conv]
  - install magic-mime      1.0.0                       [required by cohttp]
  - install base64          2.2.0                       [required by cohttp, js_of_ocaml]
  - install easy-format     1.3.1                       [required by yojson]
  - install menhir          20171222                    [required by js_of_ocaml]
  - install cmdliner        1.0.2                       [required by cohttp, js_of_ocaml]
  - install re              1.7.1                       [required by cohttp]
  - install cppo            1.6.0                       [required by js_of_ocaml, lwt]
  - install sexplib         113.33.03                   [required by cohttp]
  - install ppx_core        113.33.03                   [required by ppx_fields_conv]
  - install fieldslib       113.33.03                   [required by cohttp]
  - install biniou          1.2.0                       [required by yojson]
  - install fmt             0.8.5                       [required by cohttp]
  - install ocplib-endian   1.0                         [required by cstruct]
  - install cppo_ocamlbuild 1.6.0                       [required by lwt]
  - install ppx_optcomp     113.33.03                   [required by conduit]
  - install yojson          1.4.0                       [required by js_of_ocaml]
  - install cstruct         3.0.2                       [required by conduit]
  - install ppx_deriving    4.1.5                       [required by cohttp, js_of_ocaml]
  - install lwt             2.7.1    
  - install ppx_driver      113.33.04                   [required by conduit]
  - install js_of_ocaml     2.8.4    
  - install ppx_type_conv   113.33.03                   [required by ppx_fields_conv]
  - install logs            0.6.2                       [required by cohttp]
  - install ppx_sexp_conv   113.33.03                   [required by cohttp]
  - install ppx_fields_conv 113.33.03                   [required by cohttp]
  - install uri             1.9.2                       [required by cohttp]
  - install ipaddr          2.7.2                       [required by conduit]
  - install conduit         0.15.0                      [required by cohttp]
  - install cohttp          0.22.0   
===== 31 to install =====
Do you want to continue ? [Y/n] Y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[base64] Archive in cache
[biniou] Archive in cache
[cmdliner] Archive in cache
[cohttp] Archive in cache
[conduit] Archive in cache
[cppo] Archive in cache
[cppo_ocamlbuild] Archive in cache
[cstruct] Archive in cache
[easy-format] Archive in cache
[fieldslib] Archive in cache
[fmt] Archive in cache
[ipaddr] Archive in cache
[js-build-tools] Archive in cache
[js_of_ocaml] Archive in cache
[logs] Archive in cache
[lwt] Archive in cache
[magic-mime] Archive in cache
[menhir] Archive in cache
[ocplib-endian] Archive in cache
[ppx_core] Archive in cache
[ppx_deriving] Archive in cache
[ppx_driver] Archive in cache
[ppx_fields_conv] Archive in cache
[ppx_optcomp] Archive in cache
[ppx_sexp_conv] Archive in cache
[ppx_type_conv] Archive in cache
[re] Archive in cache
[sexplib] Archive in cache
[stringext] Archive in cache
[uri] Archive in cache
[yojson] Archive in cache

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of cppo failed at "jbuilder build -p cppo -j 4".
[ERROR] The compilation of easy-format failed at "jbuilder build -p easy-format -j 4".
[ERROR] The compilation of cmdliner failed at "ocaml pkg/pkg.ml build --pinned false".
[ERROR] The compilation of base64 failed at "jbuilder build -p base64 -j 4".
[ERROR] The compilation of menhir failed at "make -f Makefile PREFIX=/Users/robertosaccon/.opam/system
        USE_OCAMLFIND=true docdir=/Users/robertosaccon/.opam/system/doc/menhir
        libdir=/Users/robertosaccon/.opam/system/lib/menhir mandir=/Users/robertosaccon/.opam/system/man/man1".
[ERROR] The compilation of stringext failed at "jbuilder build -p stringext -j 4".
[ERROR] The compilation of js-build-tools failed at "make".
[ERROR] The compilation of magic-mime failed at "make install".
[ERROR] The compilation of re failed at "ocaml setup.ml -install".
Processing 28/31: [re: ocamlfind remove]
#=== ERROR while installing base64.2.2.0 ======================================#
# opam-version 1.2.2
# os           darwin
# command      jbuilder build -p base64 -j 4
# path         /Users/robertosaccon/.opam/system/build/base64.2.2.0
# compiler     system (4.02.3)
# exit-code    127
# env-file     /Users/robertosaccon/.opam/system/build/base64.2.2.0/base64-86459-0c525f.env
# stdout-file  /Users/robertosaccon/.opam/system/build/base64.2.2.0/base64-86459-0c525f.out
# stderr-file  /Users/robertosaccon/.opam/system/build/base64.2.2.0/base64-86459-0c525f.err

#=== ERROR while installing cmdliner.1.0.2 ====================================#
# opam-version 1.2.2
# os           darwin
# command      ocaml pkg/pkg.ml build --pinned false
# path         /Users/robertosaccon/.opam/system/build/cmdliner.1.0.2
# compiler     system (4.02.3)
# exit-code    2
# env-file     /Users/robertosaccon/.opam/system/build/cmdliner.1.0.2/cmdliner-86459-8c0dd3.env
# stdout-file  /Users/robertosaccon/.opam/system/build/cmdliner.1.0.2/cmdliner-86459-8c0dd3.out
# stderr-file  /Users/robertosaccon/.opam/system/build/cmdliner.1.0.2/cmdliner-86459-8c0dd3.err
### stdout ###
# No such package: topkg
### stderr ###
# File "pkg/pkg.ml", line 4, characters 5-10:
# Error: Unbound module Topkg

#=== ERROR while installing cppo.1.6.0 ========================================#
# opam-version 1.2.2
# os           darwin
# command      jbuilder build -p cppo -j 4
# path         /Users/robertosaccon/.opam/system/build/cppo.1.6.0
# compiler     system (4.02.3)
# exit-code    127
# env-file     /Users/robertosaccon/.opam/system/build/cppo.1.6.0/cppo-86459-0f1b61.env
# stdout-file  /Users/robertosaccon/.opam/system/build/cppo.1.6.0/cppo-86459-0f1b61.out
# stderr-file  /Users/robertosaccon/.opam/system/build/cppo.1.6.0/cppo-86459-0f1b61.err

#=== ERROR while installing easy-format.1.3.1 =================================#
# opam-version 1.2.2
# os           darwin
# command      jbuilder build -p easy-format -j 4
# path         /Users/robertosaccon/.opam/system/build/easy-format.1.3.1
# compiler     system (4.02.3)
# exit-code    127
# env-file     /Users/robertosaccon/.opam/system/build/easy-format.1.3.1/easy-format-86459-2913ab.env
# stdout-file  /Users/robertosaccon/.opam/system/build/easy-format.1.3.1/easy-format-86459-2913ab.out
# stderr-file  /Users/robertosaccon/.opam/system/build/easy-format.1.3.1/easy-format-86459-2913ab.err

#=== ERROR while installing js-build-tools.113.33.04 ==========================#
# opam-version 1.2.2
# os           darwin
# command      make
# path         /Users/robertosaccon/.opam/system/build/js-build-tools.113.33.04
# compiler     system (4.02.3)
# exit-code    2
# env-file     /Users/robertosaccon/.opam/system/build/js-build-tools.113.33.04/js-build-tools-86459-e0259d.env
# stdout-file  /Users/robertosaccon/.opam/system/build/js-build-tools.113.33.04/js-build-tools-86459-e0259d.out
# stderr-file  /Users/robertosaccon/.opam/system/build/js-build-tools.113.33.04/js-build-tools-86459-e0259d.err
### stdout ###
# [...]
# pkg_ocamlbuild: ...................................... /usr/local/lib/node_modules/reason-cli/r/3____________________________________________/i/opam__slash__ocamlfind-1.7.3-6d029a7d/lib/ocaml/ocamlbuild
# 
# ./setup.exe -build 
# ocamlfind ocamlopt unix.cmxa -I /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuildlib.cmxa -linkpkg myocamlbuild.ml /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# + ocamlfind ocamlopt unix.cmxa -I /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuildlib.cmxa -linkpkg myocamlbuild.ml /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# File "myocamlbuild.ml", line 1:
# Error: /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild_plugin.cmi
# is not a compiled interface for this version of OCaml.
# It seems to be for a newer version of OCaml.
# Command exited with code 2.
### stderr ###
# E: Failure("Command ''/usr/local/bin/ocamlbuild' ocamlbuild_goodies/jane_street_ocamlbuild_goodies.cma ocamlbuild_goodies/jane_street_ocamlbuild_goodies.cmxa ocamlbuild_goodies/jane_street_ocamlbuild_goodies.a ocamlbuild_goodies/jane_street_ocamlbuild_goodies.cmxs oasis2opam-install/oasis2opam_install.cma oasis2opam-install/oasis2opam_install.cmxa oasis2opam-install/oasis2opam_install.a oasis2opam-install/oasis2opam_install.cmxs -use-ocamlfind -tag debug' terminated with error code 10")
# make: *** [build] Error 1

#=== ERROR while installing magic-mime.1.0.0 ==================================#
# opam-version 1.2.2
# os           darwin
# command      make install
# path         /Users/robertosaccon/.opam/system/build/magic-mime.1.0.0
# compiler     system (4.02.3)
# exit-code    2
# env-file     /Users/robertosaccon/.opam/system/build/magic-mime.1.0.0/magic-mime-86459-52d546.env
# stdout-file  /Users/robertosaccon/.opam/system/build/magic-mime.1.0.0/magic-mime-86459-52d546.out
# stderr-file  /Users/robertosaccon/.opam/system/build/magic-mime.1.0.0/magic-mime-86459-52d546.err
### stdout ###
# ocaml setup.ml -install 
### stderr ###
# ocamlfind: Bad configuration: Cannot mkdir /usr/local/lib/node_modules/reason-cli/r/3____________________________________________/s/reason_cli-3.0.1-0800ebed/lib/magic-mime because a path component does not exist or is not a directory
# E: Failure("Command ''/usr/local/lib/node_modules/reason-cli/r/3____________________________________________/i/opam__slash__ocamlfind-1.7.3-6d029a7d/bin/ocamlfind' install magic-mime ./META _build/magic_mime.cmx _build/mime_types.cmx _build/magic_mime.annot _build/magic_mime.cmt _build/magic_mime.cmti _build/magic_mime.cmi _build/mime_types.annot _build/mime_types.cmt _build/mime_types.cmti _build/mime_types.cmi _build/magic-mime.cmxs _build/magic-mime.a _build/magic-mime.cmxa _build/magic-mime.cma ./mime_types.mli ./magic_mime.mli' terminated with error code 2")
# make: *** [install] Error 1

#=== ERROR while installing menhir.20171222 ===================================#
# opam-version 1.2.2
# os           darwin
# command      make -f Makefile PREFIX=/Users/robertosaccon/.opam/system USE_OCAMLFIND=true docdir=/Users/robertosaccon/.opam/system/doc/menhir libdir=/Users/robertosaccon/.opam/system/lib/menhir mandir=/Users/robertosaccon/.opam/system/man/man1
# path         /Users/robertosaccon/.opam/system/build/menhir.20171222
# compiler     system (4.02.3)
# exit-code    2
# env-file     /Users/robertosaccon/.opam/system/build/menhir.20171222/menhir-86459-af3201.env
# stdout-file  /Users/robertosaccon/.opam/system/build/menhir.20171222/menhir-86459-af3201.out
# stderr-file  /Users/robertosaccon/.opam/system/build/menhir.20171222/menhir-86459-af3201.err
### stdout ###
# ocamlopt.opt unix.cmxa -I /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# + ocamlopt.opt unix.cmxa -I /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# File "myocamlbuild.ml", line 1:
# Error: /usr/local/Cellar/ocamlbuild/0.11.0_2/lib/ocamlbuild/ocamlbuild_plugin.cmi
# is not a compiled interface for this version of OCaml.
# It seems to be for a newer version of OCaml.
# Command exited with code 2.
### stderr ###
# make[2]: *** [stage1] Error 10
# make[1]: *** [bootstrap] Error 2
# make: *** [all] Error 2

#=== ERROR while installing re.1.7.1 ==========================================#
# opam-version 1.2.2
# os           darwin
# command      ocaml setup.ml -install
# path         /Users/robertosaccon/.opam/system/build/re.1.7.1
# compiler     system (4.02.3)
# exit-code    1
# env-file     /Users/robertosaccon/.opam/system/build/re.1.7.1/re-86459-42737e.env
# stdout-file  /Users/robertosaccon/.opam/system/build/re.1.7.1/re-86459-42737e.out
# stderr-file  /Users/robertosaccon/.opam/system/build/re.1.7.1/re-86459-42737e.err
### stderr ###
# ocamlfind: Bad configuration: Cannot mkdir /usr/local/lib/node_modules/reason-cli/r/3____________________________________________/s/reason_cli-3.0.1-0800ebed/lib/re because a path component does not exist or is not a directory
# E: Failure("Command ''/usr/local/lib/node_modules/reason-cli/r/3____________________________________________/i/opam__slash__ocamlfind-1.7.3-6d029a7d/bin/ocamlfind' install re lib/META _build/lib/re_emacs.cmx _build/lib/re_emacs.annot _build/lib/re_emacs.cmt _build/lib/re_emacs.cmti _build/lib/re_emacs.cmi _build/lib/re_emacs.cmxs _build/lib/re_emacs.a _build/lib/re_emacs.cmxa _build/lib/re_emacs.cma lib/re_emacs.mli _build/lib/re_glob.cmx _build/lib/re_glob.annot _build/lib/re_glob.cmt _build/lib/re_glob.cmti _build/lib/re_glob.cmi _build/lib/re_glob.cmxs _build/lib/re_glob.a _build/lib/re_glob.cmxa _build/lib/re_glob.cma lib/re_glob.mli _build/lib/re_pcre.cmx _build/lib/re_pcre.annot _build/lib/re_pcre.cmt _build/lib/re_pcre.cmti _build/lib/re_pcre.cmi _build/lib/re_pcre.cmxs _build/lib/re_pcre.a _build/lib/re_pcre.cmxa _build/lib/re_pcre.cma lib/re_pcre.mli _build/lib/re_perl.cmx _build/lib/re_perl.annot _build/lib/re_perl.cmt _build/lib/re_perl.cmti _build/lib/re_perl.cmi _build/lib/re_perl.cmxs _build/lib/re_perl.a _build/lib/re_perl.cmxa _build/lib/re_perl.cma lib/re_perl.mli _build/lib/re_posix.cmx _build/lib/re_posix.annot _build/lib/re_posix.cmt _build/lib/re_posix.cmti _build/lib/re_posix.cmi _build/lib/re_posix.cmxs _build/lib/re_posix.a _build/lib/re_posix.cmxa _build/lib/re_posix.cma lib/re_posix.mli _build/lib/re_str.cmx _build/lib/re_str.annot _build/lib/re_str.cmt _build/lib/re_str.cmti _build/lib/re_str.cmi _build/lib/re_str.cmxs _build/lib/re_str.a _build/lib/re_str.cmxa _build/lib/re_str.cma lib/re_str.mli _build/lib/re.cmx _build/lib/re_fmt.cmx _build/lib/re_cset.cmx _build/lib/re_automata.cmx _build/lib/re.annot _build/lib/re.cmt _build/lib/re.cmti _build/lib/re.cmi _build/lib/re.cmxs _build/lib/re.a _build/lib/re.cmxa _build/lib/re.cma lib/re.mli' terminated with error code 2")

#=== ERROR while installing stringext.1.5.0 ===================================#
# opam-version 1.2.2
# os           darwin
# command      jbuilder build -p stringext -j 4
# path         /Users/robertosaccon/.opam/system/build/stringext.1.5.0
# compiler     system (4.02.3)
# exit-code    127
# env-file     /Users/robertosaccon/.opam/system/build/stringext.1.5.0/stringext-86459-a7c577.env
# stdout-file  /Users/robertosaccon/.opam/system/build/stringext.1.5.0/stringext-86459-a7c577.out
# stderr-file  /Users/robertosaccon/.opam/system/build/stringext.1.5.0/stringext-86459-a7c577.err

=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions were aborted
  - install biniou          1.2.0    
  - install cohttp          0.22.0   
  - install conduit         0.15.0   
  - install cppo_ocamlbuild 1.6.0    
  - install cstruct         3.0.2    
  - install fieldslib       113.33.03
  - install fmt             0.8.5    
  - install ipaddr          2.7.2    
  - install js_of_ocaml     2.8.4    
  - install logs            0.6.2    
  - install lwt             2.7.1    
  - install ocplib-endian   1.0      
  - install ppx_core        113.33.03
  - install ppx_deriving    4.1.5    
  - install ppx_driver      113.33.04
  - install ppx_fields_conv 113.33.03
  - install ppx_optcomp     113.33.03
  - install ppx_sexp_conv   113.33.03
  - install ppx_type_conv   113.33.03
  - install sexplib         113.33.03
  - install uri             1.9.2    
  - install yojson          1.4.0    
The following actions failed
  - install base64         2.2.0    
  - install cmdliner       1.0.2    
  - install cppo           1.6.0    
  - install easy-format    1.3.1    
  - install js-build-tools 113.33.04
  - install magic-mime     1.0.0    
  - install menhir         20171222 
  - install re             1.7.1    
  - install stringext      1.5.0    
No changes have been performed
robertos-mbp:ethereum-re robertosaccon$ 

Next problem: to integrate the JS version of ethereum-re into my app, I just added the dependency to bsconfig and package.json (as local file package), but I am using parcel for packaging and dev-server and as editor vscode (with reason.diagnostics.tools enabled) and this all use bsb as default, which fail to ignore / skip the native stuff and abort with:

  We've found a bug for you!
  /Users/robertosaccon/kelor-reason/node_modules/ethereum-re/src/native-code/libNative.re 1:6-8

  1 │ open Lwt;
  2 │
  3 │ let send = (~conn: Types.connection, ~uri, ~params: Json.t, ~method, ~i
      d, ()) =>

  The module or file Lwt can't be found.

I guess first I need to adapt my toolchain, before being able to use ethereum-re. Such as using "bs-platform": "bsansouci/bsb-native" and either tweak things so parcel understands the bsb needs to be run with argument -backend js or find a different solution for packaging / dev-server such as webpack, which I had before.

fxfactorial commented 6 years ago

Ah, I didn't get a change yet to write better instructions.

So:

you need to be on the bucklescript switch

$ opam switch 4.02.3+buckle-master

And make sure to do:

$ eval `opam config env`

Then:

opam install lwt cotthp result ppx_deriving -y

And then:

$ yarn --production=false

and then:

./node_modules/.bin/bsb -make-world -backend native -w
rsaccon commented 6 years ago

ok, thanks a lot, now building native works as expected. Still need to adapt my toolchain but that is not an issue with ethereum-re, so I am gonna close this.

rsaccon commented 6 years ago

Ups, in the README is a typo: should be cohttp, but is cotthp

fxfactorial commented 6 years ago

you're right, fixed

rsaccon commented 6 years ago

great, thanks, closing it (again)