tuareg mode emacs ocaml not found

1.5k views Asked by At

I am running emacs 24.3 on mac os x 10.9. I have installed the tuareg-mode for ocaml programming but am unable to compile using the command C-c C-b. On pressing the same, the minibuffer asks me about 'Caml toplevel to run: ocaml'. When I press enter it shows the error "Searching for program: No such file or directory, ocaml". What am I missing?

2

There are 2 answers

1
user2239690 On BEST ANSWER

So I found this cool mode that autoloads the shell variables into emacs environment for mac users. Very handy:

https://github.com/purcell/exec-path-from-shell

Just install it and update your .emacs file and you are set.

6
Alex Ott On

you need to setup PATH environment variable & the Emacs's exec-path variable to correct values. One possibility is to use something like (in your ~/.emacs):

(defun set-exec-path-from-shell-PATH ()
  (let ((path-from-shell (shell-command-to-string "$SHELL -c 'echo $PATH'")))
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))
(when window-system (set-exec-path-from-shell-PATH))

to get the PATH from shell and both variables correctly. One advantage of this is that you will setup PATH only in one place - in your shell init script.