0

我目前安装了 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

我应该怎么办?

谢谢!

4

1 回答 1

3

Opam 的“系统编译器”,默认使用 on opam init,是一种混合设置,其中软件包安装在本地 opam 沙箱中,但使用来自系统 ( /usr) 的编译器。请参阅opam switch命令以将沙箱与 opam 编译的编译器一起使用,或切换回来。

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

应该发生的事情取决于lwtand ocamlbuildocamlfind首先安装 opam ;然后PATH设置~/.opam/system/bin/为首先,并且始终选择这些已安装的二进制文件。这肯定是哪里出了问题,因为日志的结尾显示了它/usr/bin/ocamlbuild被调用了。

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

  • 检查 ocamlbuild 和 ocamlfind 是否由 opam 正确安装,以及是否存在~/.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 编译器的标准(非系统)开关可以解决此问题。不过编译需要一点时间。

于 2017-04-28T13:28:13.597 回答