ocaml命令行找不到 “topfind”

标签 ocaml opam ocaml-toplevel

我已经安装了opam ,运行opam init ,运行opam switch 4.06.0创建了 4.06.0 ~/.opam里面的目录,运行“eval opam confing env ”,导出 $OCAML_TOPLEVEL_PATH~/.opam/4.06.0/lib/toplevel除其他事项外,启动时ocaml我得到了可怕的:

$ ocaml
        OCaml version 4.06.0

Cannot find file topfind.
Unknown directive `camlp4o'.
# 

我看过thisthis这两个都没有解决我的问题,我已经束手无策了(第一次设置 OCaml)。这是我的~/.ocamlinit :

(* Added by OPAM. *)
let () =
  try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
  with Not_found -> ()
;;
#use "topfind"
#camlp4o
#thread
#require "core.top"
#require "core.syntax"

编辑:看起来我还没有安装 core ,安装core解决了这个问题,但现在在大量的导入诊断中我得到了:

Exception:
Invalid_argument
 "The ocamltoplevel.cma library from compiler-libs cannot be loaded inside the OCaml toplevel".

然后再往下一点:

Raised at file "pervasives.ml", line 33, characters 25-45
Called from file "toplevel/toploop.ml", line 468, characters 4-128
Called from file "toplevel/topdirs.ml", line 144, characters 10-51
    Camlp4 Parsing version 4.06.0

最佳答案

你应该运行

eval `opam config env`

注意反引号。在大多数现代键盘上,它们通常位于 1 键的左侧。该命令不应输出任何内容,如果您看到任何输出,则意味着您运行不正确。每次启动新 shell 时都必须运行此命令来激活 opam 安装(除非您已将此命令放入 shell 初始化脚本中,例如 .bashrc)

如果问题仍然存在,请确保您已安装 ocamlfind 软件包,

opam install ocamlfind

关于ocaml命令行找不到 “topfind”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47508389/

相关文章:

ocaml - 沙丘 : build library and access it in another project and hide or make inaccessible private or implementation modules

build - 在 OPAM 构建中检测目标架构

ocaml - 为什么我可以添加任意数量的 ;到底在OCaml顶层就行了?

load - 可编译但不符合顶层的 Ocaml 代码

functional-programming - 函数式编程函数混淆

ocaml - 为什么 Array.map 比尾递归映射(相当)快?

compiler-errors - OCaml 警告 31、编译器库和 ppx

ocaml - 使用 OPAM 安装 camlimages

OCaml:测量顶层的执行时间

list - 我想在 "then"语句中的 "if.. then.. else"语句之后做两件事