npm-opam / cohttp

1 stars 0 forks source link

npm install fails: unbound module OUnit2 #1

Open IwanKaramazow opened 7 years ago

IwanKaramazow commented 7 years ago

npm install @ocaml-alpha/cohttp

Results in:

+ /Users/Iwan/Development/test/node_modules/ocamlfind-actual/_build/ocamlfind/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package oUnit -package unix -o qCheck_ounit.cmi qCheck_ounit.mli
File "qCheck_ounit.mli", line 31, characters 50-61:
Error: Unbound module OUnit2
Command exited with code 2.
Compilation unsuccessful after building 10 targets (0 cached) in 00:00:00.
E: Failure("Command ''/Users/Iwan/Development/test/node_modules/ocaml/bin/ocamlbuild' qcheck.cma qcheck.cmxa qcheck.a qcheck.cmxs qcheck_ounit.cma qcheck_ounit.cmxa qcheck_ounit.a qcheck_ounit.cmxs qCheck_ounit_test.byte -tag debug' terminated with error code 10")
make: *** [all] Error 1
/Users/Iwan/Development/test
└── (empty)

How can I fix this?

jordwalke commented 7 years ago

I do not believe that npm install x commands work well. I believe you need to add it as a dependency of a project and then run npm install for that project (wipe the node_modules first).

sgrove commented 7 years ago

I get the same error trying to add it to package.json on a fresh git checkout

Finished, 1 target (0 cached) in 00:00:00.
+ /Users/s/code/ocaml/ip/node_modules/ocamlfind-actual/_build/ocamlfind/bin/ocamlfind ocamlc -c -g -annot -bin-annot -package oUnit -package unix -o qCheck_ounit.cmi qCheck_ounit.mli
File "qCheck_ounit.mli", line 31, characters 50-61:
Error: Unbound module OUnit2
Command exited with code 2.
Compilation unsuccessful after building 10 targets (0 cached) in 00:00:00.
E: Failure("Command ''/Users/s/code/ocaml/ip/node_modules/ocaml/bin/ocamlbuild' qcheck.cma qcheck.cmxa qcheck.a qcheck.cmxs qcheck_ounit.cma qcheck_ounit.cmxa qcheck_ounit.a qcheck_ounit.cmxs qCheck_ounit_test.byte -tag debug' terminated with error code 10")
make: *** [all] Error 1
jordwalke commented 7 years ago

Trying to repo, thanks.

jordwalke commented 7 years ago

Okay, I did a little debugging and documented my steps for debugging npm packages here:

    "postinstall": "eval $(dependencyEnv) && nopam && ocaml setup.ml -configure --prefix $opam_prefix --${ounit_enable:-disable}-ounit && make all install_file && make install && (opam-installer --prefix=$opam_prefix || true)"

It's definitely the postinstall that is failing, and I think it's because of the --${ounit_enable:-disable}-ounit part. When I change it to --disable-ounit it passes. But since it has a dependency on ounit, I think we want it to become --enable-ounit. Either way, nothing is going to dynamically make that flag become what we want it to be - I think it should have been converted to --disable-ounit or --enable-ounit at the time we converted the package. Here's the logic that does it.

https://github.com/yunxing/opam-npm/blob/master/OPAMToNPM.py

@yunxing Did we just miss a regex?

yunxing commented 7 years ago

looking into this. Sorry I missed the notification.

@jordwalke I don't understand where the disable-ounit or enable-ounit comes from. In this opam file: https://github.com/ocaml/opam-repository/blob/master/packages/cohttp/cohttp.0.21.0/opam, it says nothing about ounit in the installation step.

jordwalke commented 7 years ago

Where did this postinstall come from?

"postinstall": "eval $(dependencyEnv) && nopam && ocaml setup.ml -configure --prefix $opam_prefix --${ounit_enable:-disable}-ounit && make all install_file && make install && (opam-installer --prefix=$opam_prefix || true)"

Is it possibly a different version that was converted?