emacs ocaml REPL:“搜索程序:没有这样的文件或目录,ocaml”

问题描述 投票:0回答:2

我正在尝试在VirtualBox上的Ubuntu 16.04.3中设置OCaml。我是所有人的新手;请原谅我的无知。我用opam安装了

wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s /usr/local/bin

并补充说

. /home/<username>/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

根据~/.profile安装后的说明,我的opam文件。我使用tuareg使用opam install tuaregGNU emacs 24.5.1安装了sudo apt-get install emacs

当我试图通过在emacs中键入ocamlM-x run-ocaml来使用return REPL时,我得到了OCaml REPL to run: ocaml;当我再次击中enter时,我得到了

Searching for program: no such file or directory, ocaml

我然后尝试M-x shell看看我是否可以从shell运行ocaml,我注意到每次我想从终端/ shell运行opam switch时我都需要使用ocaml;如果我直接键入ocaml,我会得到

The program 'ocaml' is currently not installed. You can install it by typing: sudo apt-get install ocaml-interp

我不确定这是否与我得到的问题有关。

作为第二次尝试,我回到了emacs并打了M-x run-ocaml,打了return,再次在return点击了OCaml REPL to run:(这次没有ocaml)。这开辟了一个新的缓冲区:

output file descriptor closed

但是当我尝试在新的缓冲区中输入内容时,比如1+1;;,然后点击shift-return,我得到Output file descriptor of OCaml is closed,如上所示。

我一直在阅读不同的文档和线程以获取指示,但它们都没有描述我的情况。任何帮助将非常感激!

ubuntu emacs ocaml opam
2个回答
1
投票

也许你应该尝试像M-x run-ocamlreturn,然后键入类似/usr/bin/opam config exec -- ocaml(或任何你的opam安装的路径)而不是ocaml


0
投票

所以我按照realworldocaml解决了这个问题。我意识到我的帖子中有几个问题,所以我使用这个答案来分享链接中建议的解决方案。

@ ghilesZ的答案完美地解决了我的问题标题中的问题(谢谢!)。我应该在ocaml命令中添加M-x的路径(如上面的答案所示)或在~/.emacs配置文件中添加(如链接所示)。在完成下面的步骤之后,可以通过在终端中键入which ocaml来获得路径。

需要打字

eval `opam config env`

从终端运行ocaml可以通过添加到~/.bashrc文件的行来解决。这是因为在当前shell中键入命令只会为当前shell设置内容。为了使将来的shell能够自动设置,需要在登录脚本中添加它。

© www.soinside.com 2019 - 2024. All rights reserved.