0

I currently have Fedora 26 installed, and I have installed the following packages:

sudo dnf install opam ocaml gcc gcc-c++ m4 make ocamldoc sqlite-devel libcurl-devel fuse-devel zlib-devel ocaml-camlp4-devel redhat-rpm-config

This is the error I currently get trying to install utop:

#=== ERROR while installing lwt.2.7.1 =========================================#
# opam-version 1.2.2
# os           linux
# command      make build
# path         /home/z/.opam/system/build/lwt.2.7.1
# compiler     system (4.02.3)
# exit-code    2
# env-file     /home/z/.opam/system/build/lwt.2.7.1/lwt-21869-a00279.env
# stdout-file  /home/z/.opam/system/build/lwt.2.7.1/lwt-21869-a00279.out
# stderr-file  /home/z/.opam/system/build/lwt.2.7.1/lwt-21869-a00279.err
### stdout ###
# ./setup.exe -build 
# ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /usr/lib64/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# + ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /usr/lib64/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# File "myocamlbuild.ml", line 1:
# Error: Files /home/z/.opam/system/lib/cppo_ocamlbuild/ocamlbuild_cppo.cmxa
#        and /usr/lib64/ocaml/ocamlbuild/ocamlbuildlib.cmxa
#        make inconsistent assumptions over implementation Ocamlbuild_plugin
# Command exited with code 2.
# Makefile:33: recipe for target 'build' failed
### 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/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/logg$r/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-reac$.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-pre$mptive.a src/preemptive/lwt-preemptive.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 d$c/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

What should I do?

Thank you!

Flux
  • 9,805
  • 5
  • 46
  • 92
zeldangit
  • 45
  • 4
  • 2
    This is not a solution to your specific issue, but in general I recommend not using the system compiler (i.e., not installing any Fedora OCaml packages). I have Fedora 26, installed OPAM via its binary (using `opam-installer.sh`), then installed OCaml 4.02.3 with it, and then utop, and didn't have the issue you described. I avoid installing OCaml from distro packages because they are updated less often and are more likely to lead to odd issues, in my experience. – anol Apr 27 '17 at 16:34
  • What @anol suggests is good advice. Maybe you are simply missing an `eval $(opam config env)` before doing the install but if this doesn't solve the problem I suggest following @anol's advice. – Daniel Bünzli Apr 27 '17 at 16:46
  • Okay, I guess I'll try that. – zeldangit Apr 27 '17 at 16:46
  • That indeed worked! As a note for others, uninstalling ocaml and just using the shell opam file worked. I still think that ocamldocs is required to be installed via the package manager however. – zeldangit Apr 27 '17 at 19:54

1 Answers1

3

Opam's "system compiler", that is used by default on opam init, is an hybrid setting in which the packages are installed in the local opam sandbox, but the compiler from the system (/usr) is used. See the opam switch command to use a sandbox with a compiler compiled by opam instead, or to switch back.

Your example shows that you are using a system compiler, as provided by dnf install ocaml ; opam is consequently supposed to use e.g. /usr/bin/ocamlopt, but installed software and libs from ~/.opam/system/{bin,lib}.

What is supposed to happen is that lwt depends on ocamlbuild and ocamlfind, which opam installs first; then PATH is set so that ~/.opam/system/bin/ is first and these installed binaries are always chosen. It's where something must be going wrong, because the end of the log shows that /usr/bin/ocamlbuild was called.

It's difficult to know what without more details, and I failed to reproduce on a Fedora 25 container. But you could:

  • check if ocamlbuild and ocamlfind were properly installed by opam, and the presence of ~/.opam/system/bin/ocaml{find,build}
  • check if there is any global or environment configuration of ocamlfind that could interfere (which ocamlfind; ocamlfind printconf; opam config exec -- ocamlfind printconf).
  • check the linked environment file: /home/z/.opam/system/build/lwt.2.7.1/lwt-21869-a00279.env to see if PATH is properly defined
  • run with -v to see all commands issued by opam

Of course, as mentionned in the comments above, using a standard (i.e. non-system) switch, which includes its own OCaml compiler, would work around the issue. It takes a tad longer to compile though.

AltGr
  • 331
  • 2
  • 4