Question

I'm using Emacs 24 on OS X 10.6.8. Doing magit-status says

Searching for program: no such file or directory, git

However, the Emacs shell is able to find git, so this does not seem to be a $PATH issue. What else could it be?

Était-ce utile?

La solution

Try checking the value of exec-path variable. This controls the directories which are looked by Emacs for external executables (including git).

This is a customizable variable, and you can add the path to git to the list of existing directories.

I have the elisp snippet in my .emacs.d/init.el file for my Emacs install under OSX, which sets both the PATH and exec-path correctly.

;;; Set localized PATH for OS X
(defun my-add-path (path-element)
  "Add the specified PATH-ELEMENT to the Emacs PATH."
  (interactive "DEnter directory to be added to path: ")
  (if (file-directory-p path-element)
     (progn
       (setenv "PATH" (concat (expand-file-name path-element) path-separator (getenv "PATH")))
       (add-to-list 'exec-path (expand-file-name path-element)))))

(if (fboundp 'my-add-path)
   (let ((my-paths (list "/opt/local/bin" "/usr/local/bin" "/usr/local/git/bin")))
      (dolist (path-to-add my-paths (getenv "PATH"))
         (my-add-path path-to-add))))

Autres conseils

Emacs on OS X uses the system-wide environment variables, which can be overridden by creating a magic environment.plist XML file in the right directory. A better solution, though, is to have Emacs copy the value of $PATH from your shell, so that it matches what you see in Terminal.app.

@Anupam's answer is based on a snippet of code which I originally wrote for this purpose, but I've now improved that code and published it as a little elisp library called exec-path-from-shell which you can install from Marmalade or Melpa.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top