PATH和exec-path设置,但emacs找不到可执行文件 [英] PATH and exec-path set, but emacs does not find executable

查看:857
本文介绍了PATH和exec-path设置,但emacs找不到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.emacs包含

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

(add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
(require 'tex-site)
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)

/ usr / texbin是latex / pdflatex / ..所在的地方。
/ opt / local / bin /是可以找到gs的地方。

/usr/texbin is where latex/pdflatex/.. are located. /opt/local/bin/ is where gs can be found.

然而,当我运行preview-at-point时,显然需要胶乳和gs,我得到

And yet when I run preview-at-point, which apparently needs both latex and gs, I get

Preview-DviPS finished at Thu Dec 22 11:25:46
DviPS sentinel: Searching for program: No such file or directory, gs

这意味着可以找到乳胶,但不能gs。

which means that latex could be found all right, but not gs.

我不确定是否设置exec-path是必要的,也许PATH已经够了,但我已将其设置为调试措施。

I am not sure whether setting exec-path is necessary, perhaps PATH is enough, but I've set it as a debugging measure.

为什么emacs没有找到gs,即使它的目录在PATH和exec-path?

Why can emacs not find gs even though the directory it's in is in both PATH and exec-path?

推荐答案

如果您在Emacs中设置 $ PATH ,那么可能是在OS X上。GUI应用程序不是通过shell启动的,所以他们看到不同的环境变量。

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.

这是一个我用来确保Emacs内部的$ $ $ $ $ $ $ $ code看看我是否开火终端(,但请参阅下方的更新):

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))))

然后只需调用$ code> set-exec-path-from-shell-PATH 函数,也许从您的Emacs init文件。我保留代码 github ,BTW。

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

更新:此代码现在已被改进并发布为名为 exec-path-from-shell ;可以在Marmalade中使用可安装的软件包, Melpa

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

这篇关于PATH和exec-path设置,但emacs找不到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆