kennetpostigo/lwt-node

`esy add lwt-node` fails

despairblue opened this issue · 20 comments

I'm using Linux and I have a local installation of OPAM. In case that information helps.

Complete Output
error @opam/reason (node_modules/@opam/reason) failed to build.

The error below is likely a bug in Esy itself, please report it.

  Error: Command failed.
Exit code: 1
Command: /home/despairblue/yarn/node_modules/@esy-ocaml/ocamlrun/install/bin/ocamlrun
Arguments: /home/despairblue/yarn/node_modules/esy/bin/esyBuildPackage -B -
Directory: /home/despairblue/git/node-lwt/my-esy-project
Output:
# esy-build-package: running: 'jbuilder' 'build' '--root' '.'
    ocamldep src/reason-merlin/ocamlmerlin_reason.depends.ocamldep-output
    ocamldep src/reason-parser/menhir_error_processor.depends.ocamldep-output
    ocamldep src/ppx/ppx_react.depends.ocamldep-output
    ocamldep src/refmt/refmt_impl.depends.ocamldep-output
    ocamldep src/refmttype/reason_format_type.depends.ocamldep-output
    ocamldep src/reason-parser-tests/testOprint.depends.ocamldep-output
    ocamldep src/reason-parser/vendor/easy_format/reason.easy_format.dependsi.ocamldep-output
    ocamldep src/reason-parser/vendor/easy_format/reason.easy_format.depends.ocamldep-output
    ocamldep src/rtop/reason.rtop.depends.ocamldep-output
    ocamllex src/reason-parser/reason_lexer.ml
      ocamlc src/reason-parser/menhir_error_processor.{cmi,cmo,cmt}
    ocamldep src/ppx/ppx_react.dependsi.ocamldep-output
    ocamldep src/reason-parser/vendor/cmdliner/reason.cmdliner.dependsi.ocamldep-output
    ocamldep src/reason-parser/vendor/cmdliner/reason.cmdliner.depends.ocamldep-output
      ocamlc src/reason-parser/vendor/easy_format/easy_format.{cmi,cmti}
      ocamlc src/reason-parser/vendor/cmdliner/cmdliner.{cmi,cmti}
    ocamlopt src/reason-parser/menhir_error_processor.{cmx,o}
      ocamlc src/reason-parser/vendor/easy_format/easy_format.{cmo,cmt}
    ocamlopt src/reason-parser/vendor/easy_format/easy_format.{cmx,o}
  ocamlbuild src/reasonbuild/myocamlbuild
ocamlopt.opt unix.cmxa -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlbuild-0.12.0-5d1c6b48/lib/ocamlbuild /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlbuild-0.12.0-5d1c6b48/lib/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlbuild-0.12.0-5d1c6b48/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
      ocamlc src/reason-parser/vendor/easy_format/reason.easy_format.cma
    ocamlopt src/reason-parser/vendor/easy_format/reason.easy_format.{a,cmxa}
    ocamlopt src/reason-parser/menhir_error_processor.exe
    ocamlopt src/reason-parser/vendor/easy_format/reason.easy_format.cmxs
    ocamlopt src/reason-parser/vendor/cmdliner/cmdliner.{cmx,o}
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 427, characters 15-32:
Warning 3: deprecated: String.capitalize
Use String.capitalize_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 428, characters 15-31:
Warning 3: deprecated: String.uppercase
Use String.uppercase_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 507, characters 16-32:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 529, characters 20-36:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 534, characters 19-35:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 534, characters 45-61:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
File "src/reason-parser/vendor/cmdliner/cmdliner.ml", line 917, characters 31-47:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
    ocamlopt src/reason-parser/vendor/cmdliner/reason.cmdliner.{a,cmxa}
        bash src/reason-parser/reason_parser.messages
Read 0 sample input sentences and 0 error messages.
      menhir src/reason-parser/reason_parser_message.ml
Read 0 sample input sentences and 0 error messages.
      menhir src/reason-parser/reason_parser.{cmly,ml,mli}
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
    ocamldep src/reason-parser/reason.dependsi.ocamldep-output
      ocamlc src/reason-parser/reason_parser.{cmi,cmti}
menhir_error_processor src/reason-parser/reason_parser_explain_raw.ml
    ocamldep src/reason-parser/reason.depends.ocamldep-output
      ocamlc src/reason-parser/reason_config.{cmi,cmo,cmt}
      ocamlc src/reason-parser/reason_heuristics.{cmi,cmo,cmt}
      ocamlc src/reason-parser/reason_parser_message.{cmi,cmo,cmt}
      ocamlc src/reason-parser/reason_lexer.{cmi,cmo,cmt}
    ocamlopt src/reason-parser/reason_config.{cmx,o}
      ocamlc src/reason-parser/syntax_util.{cmi,cmo,cmt}
      ocamlc src/reason-parser/reason_oprint.{cmi,cmo,cmt}
File "src/reason-parser/reason_oprint.ml", line 203, characters 27-42:
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 8.5)
    ocamlopt src/reason-parser/reason_heuristics.{cmx,o}
    ocamlopt src/reason-parser/reason_parser_message.{cmx,o}
    ocamlopt src/reason-parser/syntax_util.{cmx,o}
    ocamlopt src/reason-parser/reason_oprint.{cmx,o}
File "src/reason-parser/reason_oprint.ml", line 203, characters 27-42:
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 8.5)
      ocamlc src/reason-parser/reason_pprint_ast.{cmi,cmo,cmt}
      ocamlc src/reason-parser/reason_parser_explain_raw.{cmi,cmo,cmt}
    ocamlopt src/reason-parser/reason_parser_explain_raw.{cmx,o}
      ocamlc src/reason-parser/reason_parser_explain.{cmi,cmo,cmt}
File "src/reason-parser/reason_parser_explain.ml", line 38, characters 15-34:
Warning 3: deprecated: String.uncapitalize
Use String.uncapitalize_ascii instead.
      ocamlc src/reason-parser/reason_toolchain.{cmi,cmo,cmt}
      ocamlc src/reason-merlin/ocamlmerlin_reason.{cmi,cmo,cmt}
      ocamlc src/ppx/ppx_react.{cmi,cmo,cmt}
      ocamlc src/reason-parser-tests/testOprint.{cmi,cmo,cmt}
      ocamlc src/rtop/reason_util.{cmi,cmo,cmt}
      ocamlc src/ppx/reactjs_jsx_ppx_v2.{cmi,cmti}
      ocamlc src/ppx/reactjs_jsx_ppx_v3.{cmi,cmti}
      ocamlc src/refmt/package.{cmi,cmo,cmt}
      ocamlc src/refmt/printer_maker.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /home/despairblue/.esy/3______________________________________________________________/i/ocaml-4.6.1-2f0a0fce/bin/ocamlc.opt -w -40 -g -bin-annot -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__menhir-20171013.0.0-32d1b066/lib/menhirLib -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocaml_migrate_parsetree-1.0.7-314f3abb/lib/ocaml-migrate-parsetree -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml/compiler-libs -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__result-1.2.0-560456b7/lib/result -I src/reason-parser -I src/reason-parser/vendor/cmdliner -I src/reason-parser/vendor/easy_format -no-alias-deps -I src/refmt -o src/refmt/printer_maker.cmo -c -impl src/refmt/printer_maker.ml)
File "src/refmt/printer_maker.ml", line 1:
Error: The files /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocaml_migrate_parsetree-1.0.7-314f3abb/lib/ocaml-migrate-parsetree/migrate_parsetree.cmi
       and /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__result-1.2.0-560456b7/lib/result/result.cmi
       make inconsistent assumptions over interface Result

Waiting for 3 jobs to finish.
esy-build-package: run
                   ['/home/despairblue/.esy/3______________________________________________________________/i/opam__slash__jbuilder-1.0.0-beta17-9fc1eed9/bin/jbuilder'
                        'build' '--root' '.']: exited with 1
    at ChildProcess.<anonymous> (/home/despairblue/yarn/node_modules/esy/bin/esy.js:39224:15)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)

@despairblue what version of esy do you have installed?

Can you please post your package.json? The cool thing about esy is that it should be possible to reproduce all build failures just by sharing a package.json.

@jordwalke

{
  "name": "my-esy-project",
  "version": "0.1.0",
  "description": "OCaml workflow with Esy",
  "author": "Danny Martini <danny@wunderflats.com>",
  "license": "MIT",
  "esy": {
    "build": [
      "jbuilder build"
    ],
    "install": [
      "esy-installer"
    ],
    "buildsInSource": "_build"
  },
  "dependencies": {
    "@esy-ocaml/esy-installer": "^0.0.0",
    "@opam/jbuilder": "^1.0.0-beta16",
    "@opam/lambda-term": "^1.11.0",
    "@opam/lwt": "^3.1.0",
    "lwt-node": "0.1.0"
  },
  "peerDependencies": {
    "ocaml": "~4.6.000"
  },
  "devDependencies": {
    "@opam/merlin": "^3.0.5",
    "ocaml": "~4.6.000"
  },
  "private": true
}

@kennetpostigo esy@0.0.70

Node v6.12.3

I generated the project using esy init

@despairblue I'm able to reproduce this now in both the lwt-node-starter that I made a month or so ago(worked back then) and using @despairblue package.json. @jordwalke should we move this issue over to esy?

probably related to: esy/esy#149 (comment)

The work around pointed out there is:

"resolutions": {
    "**/@opam/result": "1.2.0"
  },

@kennetpostigo Thanks, that fixed the problem with esy install

esy build is now failing with:

      ocamlc lib/lib__Util.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /home/despairblue/.esy/3______________________________________________________________/i/ocaml-4.6.1-2f0a0fce/bin/ocamlc.opt -w -40 -g -bin-annot -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__camomile-0.8.7-f818a794/lib/camomile -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lambda_term-1.12.0-a362e008/lib/lambda-term -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt-3.2.0-671fccee/lib/lwt -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt___react-1.1.0-27213e63/lib/lwt_react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/bytes -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml/threads -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__react-1.2.1-559cc81e/lib/react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__result-1.2.0-560456b7/lib/result -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__zed-1.6.0-af39972b/lib/zed -no-alias-deps -I lib -open Lib -o lib/lib__Util.cmo -c -impl lib/Util.ml)
File "lib/Util.ml", line 1:
Error: The files /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt-3.2.0-671fccee/lib/lwt/lwt.cmi
       and /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lambda_term-1.12.0-a362e008/lib/lambda-term/lTerm.cmi
       make inconsistent assumptions over interface Lwt
esy-build-package: run
                   ['/home/despairblue/.esy/3______________________________________________________________/i/opam__slash__jbuilder-1.0.0-beta17-9fc1eed9/bin/jbuilder'
                        'build']: exited with 1

@despairblue I see the same thing, will fix this today :)

Hey so, i've added a bin folder with an example in there that creates a dummy folder. However, when I run this outside of reason-node repo and in a example project I get the same error as you, not sure exactly why that is. @andreypopp have you ever seen an error like this with esy? Currently not sure if it's an lwt-node bug or a esy bug.

To run the example:

  1. Clone the repo
  2. esy install
  3. esy build
  4. esy make run

@despairblue the work around is to add these resolutions(thank you to @jordwalke for pointing this out):

  "resolutions": {
    "**/@opam/reason":
      "facebook/reason#b622e8f40c5605e9ab2b2423eb78053b8690d14e",
    "**/@opam/result": "1.2.0",
    "**/@opam/lwt": "3.2.0"
  },
  • The reason resolution, is so that you can use the ppx
  • The lwt one is so that it uses the lwt version that lwt-node uses.

@kennetpostigo thanks for the help 🙂

Adding the resolutions my package.json looks like:

{
  "name": "my-esy-project",
  "version": "0.1.0",
  "description": "OCaml workflow with Esy",
  "author": "Danny Martini <danny@wunderflats.com>",
  "license": "MIT",
  "esy": {
    "build": [
      "jbuilder build"
    ],
    "install": [
      "esy-installer"
    ],
    "buildsInSource": "_build"
  },
  "dependencies": {
    "@esy-ocaml/esy-installer": "^0.0.0",
    "@opam/jbuilder": "^1.0.0-beta16",
    "@opam/lambda-term": "^1.11.0",
    "@opam/lwt": "^3.1.0",
    "lwt-node": "0.1.0"
  },
  "peerDependencies": {
    "ocaml": "~4.6.000"
  },
  "devDependencies": {
    "@opam/merlin": "^3.0.5",
    "ocaml": "~4.6.000"
  },
  "resolutions": {
    "**/@opam/reason": "facebook/reason#b622e8f40c5605e9ab2b2423eb78053b8690d14e",
    "**/@opam/result": "1.2.0",
    "**/@opam/lwt": "3.2.0"
  },
  "private": true
}

After deleting ./node_modules, ./esy.lock and ~/.esy and reinstalling everything using esy again I sadly still get this:

esy install v0.0.70
info No lockfile found.
[1/4] Resolving packages...
info Fetching OPAM repository...
info Fetching OPAM repository overrides...
info Fetching OPAM URL index...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "refmterr@3.0.4" has incorrect peer dependency "ocaml@ >= 4.2.0  < 4.6.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 65.09s.
esy build v0.0.70
      ocamlc lib/lib__Util.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /home/despairblue/.esy/3______________________________________________________________/i/ocaml-4.6.1-2f0a0fce/bin/ocamlc.opt -w -40 -g -bin-annot -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__camomile-0.8.7-f818a794/lib/camomile -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lambda_term-1.12.0-3b6a8fbf/lib/lambda-term -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt-3.2.1-cf576939/lib/lwt -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt___react-1.1.0-c1935dfa/lib/lwt_react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/bytes -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml/threads -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__react-1.2.1-559cc81e/lib/react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__result-1.2.0-560456b7/lib/result -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__zed-1.6.0-af39972b/lib/zed -no-alias-deps -I lib -open Lib -o lib/lib__Util.cmo -c -impl lib/Util.ml)
File "lib/Util.ml", line 1:
Error: The files /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt-3.2.1-cf576939/lib/lwt/lwt.cmi
       and /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lambda_term-1.12.0-3b6a8fbf/lib/lambda-term/lTerm.cmi
       make inconsistent assumptions over interface Lwt
esy-build-package: run
                   ['/home/despairblue/.esy/3______________________________________________________________/i/opam__slash__jbuilder-1.0.0-beta17-9fc1eed9/bin/jbuilder'
                        'build']: exited with 1

Do you have two versions of lwt in your esy.lock? That's what this sounds like.

I would probably install lwt@3.2.0 instead of 3.1.0. Why do you have lwt installed? Is it for features not part or lwt-node? if you're just using lwt-node you don't need to installed lwt individually. Also try installing lwt-node@0.2.0.

@kennetpostigo Ah, I did not check the dependencies at all since I did not install any dependency except lwt-node explicitly. Just check my shell history and there is no invocation to esy add @opam/lwt.

Not sure where the others came from, probably from esy init.

I'll try to reproduce this.

Yep it's part of the create-esy-project template.

That LWT example from the template works if I remove the lwt dependency:

open Lwt
open LTerm_style
open LTerm_text

let hello () =
  LTerm.printls (eval [B_fg(red); S"Hello,"; E_fg; S" "; B_fg(green); S"World!"; E_fg])

The lwt-node example does not:

open LwtNode;

Node.run({
  let%lwt myDir = Fs.mkdir("myDir");
  let%lwt myDir2 = Fs.mkdir("myDir2");
  Node.resolved();
});

It does not know whatLwtNode is:

esy build v0.0.70
      ocamlc lib/lib__Util.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /home/despairblue/.esy/3______________________________________________________________/i/ocaml-4.6.1-2f0a0fce/bin/ocamlc.opt -w -40 -g -bin-annot -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__camomile-0.8.7-f818a794/lib/camomile -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lambda_term-1.12.0-3b6a8fbf/lib/lambda-term -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt-3.2.0-671fccee/lib/lwt -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__lwt___react-1.1.0-c1935dfa/lib/lwt_react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/bytes -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__ocamlfind-1.7.3--1-4a313506/lib/ocaml/threads -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__react-1.2.1-559cc81e/lib/react -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__result-1.2.0-560456b7/lib/result -I /home/despairblue/.esy/3______________________________________________________________/i/opam__slash__zed-1.6.0-af39972b/lib/zed -no-alias-deps -I lib -open Lib -o lib/lib__Util.cmo -c -impl lib/Util.re.ml)
File "lib/Util.re", line 1, characters 5-12:
Error: Unbound module LwtNode
esy-build-package: run
                   ['/home/despairblue/.esy/3______________________________________________________________/i/opam__slash__jbuilder-1.0.0-beta17-9fc1eed9/bin/jbuilder'
                        'build']: exited with 1

Sorry for bothering you that much, I hope it helps documenting a clear path for people to get started working with this or on this.

Also try installing lwt-node@0.2.0.

I missed that. Changed the package.json now accordingly and reinstalled everything but the error remains.

@despairblue do you have lwt-node specified in jbuild in libraries stanza? Can you show your jbuild file?

Hey @despairblue I just updated the lwt-node-starter, feel free to start off of that project :)

but if jbuilder cannot find lwt-node you probably aren't specifying it in the libraries field of jbuilder, also don't forget to add the lwt ppx in the pps field in jbuilder. The starter I linked above already has those for you, so feel free to just grab them or clone it.

@despairblue do you have lwt-node specified in jbuild in libraries stanza? Can you show your jbuild file?

Of course, silly me. I forgot the ppx as well. :)

@kennetpostigo Thanks in the repo I found all the pieces I needed to get it working.

Thank you all ❤️