emacs - 失败 : ocamlfind not found on path, 但未使用 -no-ocamlfind(zsh 终端)

标签 emacs ocaml

当我尝试在 emacs 中使用

编译我的文件时
ocamlbuild -use-ocamlfind main.native

我有这个错误:

ocamlbuild -use-ocamlfind main.native
Failure: ocamlfind not found on path, but -no-ocamlfind not used.

当我使用相同的命令但在我的终端(zsh)中编译它时,没有问题。我认为 emacs 找不到 ocamlfind 存在问题,但我不明白这个问题可能是什么。 (一切都是用 opam 安装的,我安装的软件包中有 OCamlbuild 和 OCamlfind,我做了 eval $(opam config env))

当我执行 M-x getenv PATH 时,我的终端中的 PATH 完全相同。

最佳答案

显然,Emacs 中的环境设置不正确。您可以从执行了 eval $(opam config env) 的终端运行 emacs,然后它将继承所有需要的变量。或者,您可以使用以下命令:

(defun opam-env ()
  (interactive nil)
  (dolist (var
           (car (read-from-string
                 (shell-command-to-string "opam config env --sexp"))))
    (setenv (car var) (cadr var))))

只要将它添加到您的初始化脚本中,并在您运行新的 Emacs 副本或切换到另一个编译器时使用 M-x opam-env 运行即可。

关于emacs - 失败 : ocamlfind not found on path, 但未使用 -no-ocamlfind(zsh 终端),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49385913/

相关文章:

algorithm - 将数字添加到函数 OCaml 中的列表

ocaml - 如何编写自定义 ppx 装饰器来重写脚本?

emacs - Org-mode capture and Evil - 自动进入插入模式

emacs - 如何列出在 common lisp 中事件的所有已定义函数和全局变量

emacs - 如何安装 emacs 颜色主题

emacs - 如何在一个屏幕是编辑器而另一个是终端仿真器的情况下切换分屏 Emacs?

regex - Emacs:如何使用正则表达式替换字符串?

将两个排序列表合并为一个排序列表的函数的 OCaml 样式

styles - ocaml 样式 : parameterize programs

ocaml - 有没有办法在 OCaml 沙丘中用连字符声明可执行文件?