PATH and exec-path set, but emacs does not find executable

后端 未结 4 1713
暗喜
暗喜 2020-12-04 17:51

My .emacs contains

(setenv \"PATH\" (concat \".:/usr/texbin:/opt/local/bin\" (getenv \"PATH\")))
(setq exec-path (append exec-path \'(\".:/usr/texbin:/opt/lo         


        
相关标签:
4条回答
  • 2020-12-04 18:30

    I hit a similar problem, but with a correct PATH, including trailing ´:´. It turned out the internal emacs shell program was missing, resulting in a ´Searching for program: No such file or directory´ message. Fixed with

    (setq shell-file-name "bash").
    
    0 讨论(0)
  • 2020-12-04 18:37

    Try replacing the second line with this:

    (setq exec-path (append exec-path '("/usr/texbin" "/opt/local/bin")))
    
    0 讨论(0)
  • 2020-12-04 18:37

    It appears you're missing a path separator : at the end of your path string.

    0 讨论(0)
  • 2020-12-04 18:43

    If you're setting $PATH inside your Emacs, you might well be on OS X. GUI applications are not started via your shell, so they see different environment variables.

    Here's a trick which I use to ensure the $PATH inside Emacs is the same one I see if I fire up a terminal (but see "update" below):

    (defun set-exec-path-from-shell-PATH ()
      "Set up Emacs' `exec-path' and PATH environment variable to match that used by the user's shell.
    
    This is particularly useful under Mac OSX, where GUI apps are not started from a shell."
      (interactive)
      (let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
        (setenv "PATH" path-from-shell)
        (setq exec-path (split-string path-from-shell path-separator))))
    

    Then simply call the set-exec-path-from-shell-PATH function, perhaps from your Emacs init file. I keep that code on github, BTW.

    Update: this code has now been improved and published as an elisp library called exec-path-from-shell; installable packages are available in MELPA.

    0 讨论(0)
提交回复
热议问题