2017-12-18 413 views
0

我試圖在Ubuntu 16.04.3在VirtualBox上設置OCaml。我對他們都是新手;請原諒我的無知。我使用emacs ocaml REPL:「搜索程序:沒有這樣的文件或目錄,ocaml」

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

安裝opam,並根據以下的opam安裝說明添加

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

~/.profile文件。我使用opam install tuaregGNU emacs 24.5.1使用sudo apt-get install emacs來安裝tuareg

當我試圖在Emacs中鍵入M-x run-ocamlreturn使用ocaml REPL,我OCaml REPL to run: ocaml;當我再次打enter,我

Searching for program: no such file or directory, ocaml 

然後我試圖M-x shell,看看我是否可以運行外殼ocaml,我發現我需要使用opam switch我想從終端/ shell中運行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,並在OCaml REPL to run:再次命中return(這次沒有ocaml)。這開闢了一個新的緩衝區:

output file descriptor closed

但是,當我試圖在新的緩衝區類的東西,說1+1;;,並創下shift-return,我得到Output file descriptor of OCaml is closed,如上圖所示。

我一直在閱讀不同的文檔和線索的指示,但他們都沒有描述我的情況。任何幫助將非常感激!

回答

1

也許你應該嘗試像M-x run-ocamlreturn,然後鍵入類似/usr/bin/opam config exec -- ocaml(或任何路徑到您的OPAM安裝),而不是ocaml

0

所以我按照realworldocaml解決了這個問題。我意識到我的帖子中有幾個問題,所以我使用這個答案 分享鏈接中建議的每個解決方案。

@ ghilesZ的回答完美地解決了我的問題標題(謝謝!)中的問題。我應該在M-x命令(正如上面的答案所示)或~/.emacs配置文件中(如鏈接所暗示的)添加ocaml的路徑。完成以下步驟後,可以通過在終端中輸入which ocaml來獲取路徑。

需鍵入

eval `opam config env` 

運行從終端ocaml可以通過將行到~/.bashrc文件來解決。這是因爲在當前shell中輸入命令只會爲當前shell設置一些東西。爲了讓將來的shell自動設置,它需要被添加到登錄腳本中。

相關問題