试图在Fedora 26中为OCaml安装utop;有关安装LWT的错误

时间:2017-04-27 16:24:01

标签: ocaml opam utop

我目前安装了Fedora 26,并且我安装了以下软件包:

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

这是我目前试图安装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

我该怎么办?

谢谢!

1 个答案:

答案 0 :(得分:3)

默认情况下opam init上使用的Opam的“系统编译器”是一个混合设置,其中包安装在本地opam沙箱中,但系统中的编译器(/usr)用来。请参阅opam switch命令以使用沙盒和opam编译的编译器,或者切换

您的示例显示您正在使用dnf install ocaml提供的系统编译器;因此,opam应该使用例如 /usr/bin/ocamlopt,但安装了来自~/.opam/system/{bin,lib}的软件和库。

假设发生的是lwt取决于ocamlbuildocamlfind,其中opam首先安装;然后设置PATH以使~/.opam/system/bin/成为第一个,并始终选择这些已安装的二进制文件。这是必须出错的地方,因为日志的结尾显示调用了/usr/bin/ocamlbuild

如果没有更多详细信息,很难知道什么,我无法在Fedora 25容器上重现。但你可以:

  • 检查opam是否正确安装了ocamlbuild和ocamlfind,以及是否存在~/.opam/system/bin/ocaml{find,build}
  • 检查ocamlfind是否存在任何可能会干扰的全局或环境配置(which ocamlfind; ocamlfind printconf; opam config exec -- ocamlfind printconf)。
  • 检查链接的环境文件:/home/z/.opam/system/build/lwt.2.7.1/lwt-21869-a00279.env以查看PATH是否已正确定义
  • 使用-v运行以查看opam发布的所有命令

当然,正如上面的评论中提到的,使用标准(非系统)开关,其中包含自己的OCaml编译器,可以解决这个问题。编译它需要更长的时间。