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 的位置。
然而,当我运行 Preview-at-point 时,它显然需要 Latex 和 gs,我得到
Preview-DviPS finished at Thu Dec 22 11:25:46
DviPS sentinel: Searching for program: No such file or directory, gs
这意味着可以找到 Latex,但不能找到 gs。
我不确定设置 exec-path 是否有必要,也许 PATH 就足够了,但我已将其设置为调试措施。
为什么 emacs 找不到 gs,即使它所在的目录同时在 PATH 和 exec-path 中?
My .emacs contains
(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 is where latex/pdflatex/.. are located.
/opt/local/bin/ is where gs can be found.
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
which means that latex could be found all right, but not gs.
I am not sure whether setting exec-path is necessary, perhaps PATH is enough, but I've set it as a debugging measure.
Why can emacs not find gs even though the directory it's in is in both PATH and exec-path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在 Emacs 中设置
$PATH
,那么您很可能使用的是 OS X。GUI 应用程序不是通过 shell 启动的,因此它们会看到不同的环境变量。这是我用来确保 Emacs 内的
$PATH
与我在启动终端时看到的相同的技巧(但请参阅下面的“更新”):然后简单地调用 set-exec-path-from-shell-PATH 函数,可能是从 Emacs init 文件中调用。顺便说一句,我将该代码保存在 github 上。
更新:此代码现已改进并作为名为 exec-path 的 elisp 库发布-来自外壳; MELPA 中提供了可安装的软件包。
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):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.
尝试用以下内容替换第二行:
Try replacing the second line with this:
我遇到了类似的问题,但路径正确,包括尾随“:”。结果发现内部 emacs shell 程序丢失,导致出现“正在搜索程序:没有这样的文件或目录”消息。
固定为
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
您似乎在路径字符串末尾缺少路径分隔符
:
。It appears you're missing a path separator
:
at the end of your path string.