Opam install utop fails after upgrade of OCaml

I just upgraded from OCaml 4.02.1 to 4.02.3.

When I tried to reinstall utop with opam install utop, it failed with the following long output reproduced below. How can I fix this ?

> opam install utop
> The following actions will be performed:
>   ∗  install lwt         2.4.8                [required by utop]
>   ∗  install lambda-term 1.8                  [required by utop]
>   ∗  install utop        1.17 
> ===== ∗  3 =====
> Do you want to continue ? [Y/n] Y

> =-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
> [default] https://opam.ocaml.org/archives/utop.1.17+opam.tar.gz downloaded
> [default] https://opam.ocaml.org/archives/lambda-term.1.8+opam.tar.gz downloaded
> [default] https://opam.ocaml.org/archives/lwt.2.4.8+opam.tar.gz downloaded

> =-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
> [ERROR] The compilation of lwt failed at "make build".
> Processing  1/3: [lwt: ocamlfind remove]
> #=== ERROR while installing lwt.2.4.8 =========================================#
> # opam-version 1.2.1
> # os           darwin
> # command      make build
> # path         /Users/jonathandoyle/.opam/system/build/lwt.2.4.8
> # compiler     system (4.02.3)
> # exit-code    2
> # env-file     /Users/jonathandoyle/.opam/system/build/lwt.2.4.8/lwt-25278-865888.env
> # stdout-file  /Users/jonathandoyle/.opam/system/build/lwt.2.4.8/lwt-25278-865888.out
> # stderr-file  /Users/jonathandoyle/.opam/system/build/lwt.2.4.8/lwt-25278-865888.err
> ### stdout ###
> # [...]
> # /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4.extend -package camlp4 -I syntax -o syntax/pa_lwt.cmi syntax/pa_lwt.mli
> # /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamldep -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4.extend -package camlp4 -syntax camlp4o -modules syntax/pa_lwt.ml > syntax/pa_lwt.ml.depends
> # /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamldep -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4.extend -package camlp4 -syntax camlp4o -modules syntax/pa_lwt_options.ml > syntax/pa_lwt_options.ml.depends
> # /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4.extend -package camlp4 -syntax camlp4o -I syntax -o syntax/pa_lwt_options.cmo syntax/pa_lwt_options.ml
> # + /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4.extend -package camlp4 -syntax camlp4o -I syntax -o syntax/pa_lwt_options.cmo syntax/pa_lwt_options.ml
> # File "syntax/pa_lwt_options.ml", line 1:
> # Error: The files /usr/local/lib/ocaml/pervasives.cmi
> #        and /usr/local/lib/ocaml/camlp4/camlp4.cmi
> #        make inconsistent assumptions over interface CamlinternalFormatBasics
> # Command exited with code 2.
> ### stderr ###
> # ocamlfind: Package `wikidoc' not found
> # E: Failure("Command ''/usr/local/bin/ocamlbuild' src/core/lwt.cma src/core/lwt.cmxa src/core/lwt.a src/core/lwt.cmxs src/logger/lwt-log.cma src/logger/lwt-log.cmxa src/logger/lwt-log.a src/logger/lwt-log.cmxs src/unix/liblwt-unix_stubs.a src/unix/dlllwt-unix_stubs.so src/unix/lwt-unix.cma src/unix/lwt-unix.cmxa src/unix/lwt-unix.a src/unix/lwt-unix.cmxs src/simple_top/lwt-simple-top.cma src/simple_top/lwt-simple-top.cmxa src/simple_top/lwt-simple-top.a src/simple_top/lwt-simple-top.cmxs src/react/lwt-react.cma src/react/lwt-react.cmxa src/react/lwt-react.a src/react/lwt-react.cmxs src/preemptive/lwt-preemptive.cma src/preemptive/lwt-preemptive.cmxa src/preemptive/lwt-preemptive.a src/preemptive/lwt-preemptive.cmxs syntax/lwt-syntax.cma syntax/lwt-syntax.cmxa syntax/lwt-syntax.a syntax/lwt-syntax.cmxs syntax/lwt-syntax-options.cma syntax/lwt-syntax-options.cmxa syntax/lwt-syntax-options.a syntax/lwt-syntax-options.cmxs syntax/lwt-syntax-log.cma syntax/lwt-syntax-log.cmxa syntax/lwt-syntax-log.a syntax/lwt-syntax-log.cmxs ppx/ppx.cma ppx/ppx.cmxa ppx/ppx.a ppx/ppx.cmxs ppx/ppx_lwt_ex.native examples/unix/logging.native examples/unix/relay.native examples/unix/parallelize.native -use-ocamlfind -tag debug' terminated with error code 10")
> # make: *** [build] Error 1



> =-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
> The following actions were aborted
>   ∗  install lambda-term 1.8 
>   ∗  install utop        1.17
> The following actions failed
>   ∗  install lwt 2.4.8
> No changes have been performed

It is trying to install a rather old version Lwt, version 2.4.8 which was released more than 2 years ago. Please try opam update && opam upgrade.

Thanks for your feedback. I did opam update && opam upgrade (successfully it seems), but i when I retry opam install utop I get a similar error message :

 opam install utop
The following actions will be performed:
  ∗  install lwt         3.0.0                [required by utop]
  ∗  install lwt_react   1.0.1                [required by lambda-term]
  ∗  install lambda-term 1.11                 [required by utop]
  ∗  install utop        2.0.1
===== ∗  4 =====
Do you want to continue ? [Y/n] Y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
Processing  1/4: [lambda-term: from default]
[default] https://opam.ocaml.org/archives/lwt_react.1.0.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/archives/lambda-term.1.11+opam.tar.gz downloaded
[default] https://opam.ocaml.org/archives/lwt.3.0.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/archives/utop.2.0.1+opam.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[ERROR] The compilation of lwt failed at "make build".
Processing  1/4: [lwt: ocamlfind remove]
#=== ERROR while installing lwt.3.0.0 =========================================#
# opam-version 1.2.1
# os           darwin
# command      make build
# path         /Users/jonathandoyle/.opam/system/build/lwt.3.0.0
# compiler     system (4.02.3)
# exit-code    2
# env-file     /Users/jonathandoyle/.opam/system/build/lwt.3.0.0/lwt-41948-335865.env
# stdout-file  /Users/jonathandoyle/.opam/system/build/lwt.3.0.0/lwt-41948-335865.out
# stderr-file  /Users/jonathandoyle/.opam/system/build/lwt.3.0.0/lwt-41948-335865.err
### stdout ###
# [...]
# /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4 -package camlp4.extend -w +A-29-58 -I src/camlp4 -o src/camlp4/pa_lwt.cmi src/camlp4/pa_lwt.mli
# /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamldep -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4 -package camlp4.extend -syntax camlp4o -modules src/camlp4/pa_lwt.ml > src/camlp4/pa_lwt.ml.depends
# /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamldep -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4 -package camlp4.extend -syntax camlp4o -modules src/camlp4/pa_lwt_options.ml > src/camlp4/pa_lwt_options.ml.depends
# /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4 -package camlp4.extend -syntax camlp4o -w +A-29-58 -w -3 -w -4 -I src/camlp4 -o src/camlp4/pa_lwt_options.cmo src/camlp4/pa_lwt_options.ml
# + /Users/jonathandoyle/.opam/system/bin/ocamlfind ocamlc -c -g -annot -bin-annot -safe-string -syntax camlp4o -syntax camlp4o -package camlp4.quotations.o -package camlp4 -package camlp4.extend -syntax camlp4o -w +A-29-58 -w -3 -w -4 -I src/camlp4 -o src/camlp4/pa_lwt_options.cmo src/camlp4/pa_lwt_options.ml
# File "src/camlp4/pa_lwt_options.ml", line 1:
# Error: The files /usr/local/lib/ocaml/pervasives.cmi
#        and /usr/local/lib/ocaml/camlp4/camlp4.cmi
#        make inconsistent assumptions over interface CamlinternalFormatBasics
# Command exited with code 2.
### stderr ###
# W: Cannot find source file matching module 'Lwt_unix' in library lwt-unix.
# W: Use InterfacePatterns or ImplementationPatterns to define this file with feature "source_patterns".
# W: Cannot find source file matching module 'Lwt_unix' in library lwt-unix.
# W: Use InterfacePatterns or ImplementationPatterns to define this file with feature "source_patterns".
# E: Failure("Command ''/usr/local/bin/ocamlbuild' src/core/lwt.cma src/core/lwt.cmxa src/core/lwt.a src/core/lwt.cmxs src/logger/lwt-log.cma src/logger/lwt-log.cmxa src/logger/lwt-log.a src/logger/lwt-log.cmxs src/unix/liblwt-unix_stubs.a src/unix/dlllwt-unix_stubs.so src/unix/lwt-unix.cma src/unix/lwt-unix.cmxa src/unix/lwt-unix.a src/unix/lwt-unix.cmxs src/simple_top/lwt-simple-top.cma src/simple_top/lwt-simple-top.cmxa src/simple_top/lwt-simple-top.a src/simple_top/lwt-simple-top.cmxs src/preemptive/lwt-preemptive.cma src/preemptive/lwt-preemptive.cmxa src/preemptive/lwt-preemptive.a src/preemptive/lwt-preemptive.cmxs src/camlp4/lwt-syntax.cma src/camlp4/lwt-syntax.cmxa src/camlp4/lwt-syntax.a src/camlp4/lwt-syntax.cmxs src/camlp4/lwt-syntax-options.cma src/camlp4/lwt-syntax-options.cmxa src/camlp4/lwt-syntax-options.a src/camlp4/lwt-syntax-options.cmxs src/camlp4/lwt-syntax-log.cma src/camlp4/lwt-syntax-log.cmxa src/camlp4/lwt-syntax-log.a src/camlp4/lwt-syntax-log.cmxs src/ppx/ppx.cma src/ppx/ppx.cmxa src/ppx/ppx.a src/ppx/ppx.cmxs src/ppx/ppx_lwt_ex.native doc/examples/unix/logging.native doc/examples/unix/relay.native doc/examples/unix/parallelize.native -use-ocamlfind -plugin-tags 'package(cppo_ocamlbuild)' -tag debug' terminated with error code 10")
# make: *** [build] Error 1



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
The following actions were aborted
  ∗  install lambda-term 1.11 
  ∗  install lwt_react   1.0.1
  ∗  install utop        2.0.1
The following actions failed
  ∗  install lwt 3.0.0
No changes have been performed

=-=- lwt.3.0.0 troubleshooting =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
=> Lwt 3.0.0 made some minor breaking changes, announced in 2.7.0. See
        https://github.com/ocsigen/lwt/issues/308

This is an annoying error that usually indicates a library was not updated when it should have been. Looks like the issue is with camlp4, so you could try opam reinstall camlp4.

However, I suspect that you did opam init a long time ago. You might be better off wiping your ~/.opam directory and starting with a fresh opam init.

/usr/local/lib/ocaml/pervasives.cmi
and /usr/local/lib/ocaml/camlp4/camlp4.cmi

This implies that you are using system installed versions of ocaml and camlp4. This is always a more fragile setup. You should do something like opam switch 4.04.1 to make a new switch and then install things in there.

If you are already on a non-system switch then something is going wrong somewhere so that one of the build systems is trying to use the system installed ocaml and camlp4 rather than the ones from the switch.

You are both absolutely right. I did opam init followed by opam switch, and reinstalled several packages. Now I have utop 2.0.1 on top of OCaml 4.04.1 working fine on my machine. Thank you so much

My suggestion here was wrong. As lpw25 pointed out, the installation is in a system location and thus doing opam install wouldn’t affect the pertinent files. But glad you got it working.

I believe I have similar issues as discussed above. I am trying to compile the ospec package, but I am getting the following error:

+ ocamlopt.opt unix.cmxa -I /Users/thegaram/.opam/system/lib/ocamlbuild /Users/thegaram/.opam/system/lib/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /Users/thegaram/.opam/system/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
File "myocamlbuild.ml", line 1:
Error: Files /Users/thegaram/.opam/system/lib/ocamlbuild/ocamlbuildlib.cmxa
       and /Users/thegaram/.opam/4.06.0/lib/ocaml/stdlib.cmxa
       make inconsistent assumptions over implementation Sys
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
E: Failure("Command ''/Users/thegaram/.opam/system/bin/ocamlbuild' src/ospec.cma src/ospec.byte -tag debug' terminated with error code 10")

I am running a fresh install of OCaml with opam version 2.0.0~rc, on a switch (4.06.0), so I’m afraid the suggestions above did not work for me. Any ideas what might be causing the problem?

Hi. OSpec uses camlp4 and is not maintained anymore, so I recommend against using it. You might want to check qcheck instead (regardless of the error message you’re getting).

3 Likes

Thanks for your suggestion @andrenth!

qcheck looks great, but it seems to be mainly for randomized unit testing. Do you happen to know any tools for BDD / e2e testing of larger projects (i.e. multiple components/services)? I’ve looked into OSpec and Cucumber, the latter also lacks official support for OCaml (there’s an unofficial half-ready library though).