ocaml命令行找不到"topfind" [英] ocaml command line cannot find “topfind”

查看:229
本文介绍了ocaml命令行找不到"topfind"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了opam,运行opam init,运行opam switch 4.06.0,在~/.opam内创建了4.06.0目录,运行"eval opam confing env",将$OCAML_TOPLEVEL_PATH导出为~/.opam/4.06.0/lib/toplevel东西,当启动ocaml时,我感到恐惧:

I've installed opam, run opam init, run opam switch 4.06.0 which created a 4.06.0 directory inside ~/.opam, run "eval opam confing env" which exports $OCAML_TOPLEVEL_PATH as ~/.opam/4.06.0/lib/toplevel amongst other things, when launching ocaml I get the dreaded:

$ ocaml
        OCaml version 4.06.0

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

我查看了

I've looked at this and this neither of which address my issue and I'm at my wits' end (first time setting up OCaml). This is my ~/.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可以解决此问题,但现在在大量导入诊断中,我得到了:

Looks like I hadn't installed core, installing core resolved that but now amongst the slew of import diagnostics I get:

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的左侧.该命令不应输出任何内容,如果看到任何输出,则表示您运行不正确.每次启动新的外壳程序时,都必须运行此命令来激活opam安装(除非已将此命令放在外壳程序初始化脚本中,例如.bashrc)

Note the backticks. They are usually located to the left of the key 1 on most modern keyboards. The command should not output anything, if you see any output it means that you're running it incorrectly. You have to run this command to activate the opam installation every time you start a new shell (unless you've put this command in your shell initialization scripts, like .bashrc)

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

If the problem persists, then make sure, that you have installed the ocamlfind package,

opam install ocamlfind

这篇关于ocaml命令行找不到"topfind"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆