Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exec-path and PATH

6 views
Skip to first unread message

Christoph Scholtes

unread,
Mar 18, 2011, 11:19:55 PM3/18/11
to emacs...@gnu.org
I was troubleshooting a problem with Emacs not being able to find
certain external programs on Windows, e.g. grep or find.

I noticed that there seem to be two ways that external programs are
invoked:

1. directly, via start-process
2. indirectly, through the shell

It was a little confusing that it was not enough to add the path to
grep.exe to exec-path for Emacs to find it. The same would work fine for
svn.exe when invoked by the vc backend.

I add the paths to certain programs in my init.el, e.g. GnuWin32 for
grep. For them to work in every situation I have to remember to add them
to exec-path and the Windows PATH environment variable. This seems
somewhat redundant, no? I would prefer only manipulating the exec-path
to tell Emacs where to find the programs.

Maybe this is a silly question, but why are some of the programs invoked
different than others?

Christoph

PS: Here is a small docfix patch for process.c for review:

=== modified file 'src/ChangeLog'
--- src/ChangeLog 2011-03-17 19:55:40 +0000
+++ src/ChangeLog 2011-03-19 02:30:14 +0000
@@ -1,3 +1,7 @@
+2011-03-19 Christoph Scholtes <cscho...@googlemail.com>
+
+ * process.c (Fstart_process): Doc fix.
+
2011-03-17 Eli Zaretskii <el...@gnu.org>

* makefile.w32-in ($(BLD)/unexw32.$(O)): Depend on $(SRC)/unexec.h.

=== modified file 'src/process.c'
--- src/process.c 2011-03-17 05:18:33 +0000
+++ src/process.c 2011-03-19 02:26:39 +0000
@@ -1510,7 +1510,7 @@
function to handle the output. BUFFER may also be nil, meaning that
this process is not associated with any buffer.

-PROGRAM is the program file name. It is searched for in PATH. If
+PROGRAM is the program file name. It is searched for in EXEC-PATH. If
nil, just associate a pty with the buffer. Remaining arguments are
strings to give program as arguments.


Eli Zaretskii

unread,
Mar 19, 2011, 4:10:07 AM3/19/11
to Christoph Scholtes, emacs...@gnu.org
> From: Christoph Scholtes <cscho...@googlemail.com>
> Date: Fri, 18 Mar 2011 21:19:55 -0600

>
> I noticed that there seem to be two ways that external programs are
> invoked:
>
> 1. directly, via start-process
> 2. indirectly, through the shell
>
> It was a little confusing that it was not enough to add the path to
> grep.exe to exec-path for Emacs to find it. The same would work fine for
> svn.exe when invoked by the vc backend.
>
> I add the paths to certain programs in my init.el, e.g. GnuWin32 for
> grep. For them to work in every situation I have to remember to add them
> to exec-path and the Windows PATH environment variable. This seems
> somewhat redundant, no? I would prefer only manipulating the exec-path
> to tell Emacs where to find the programs.

When a program is invoked via the shell, the shell will look for it
via PATH. More generally, any program invoked by Emacs that needs to
invoke other programs (e.g., compiler, Make, etc.) will look for those
subordinate programs via PATH. Only Emacs knows about exec-path. So
for your life quality in Emacs to be much better, I suggest to always
have exec-path and PATH in sync.

Maybe we should consider the possibility to automatically set PATH
from exec-path each time Emacs invokes a subprocess, because this
issue comes up time and again in gnu.emacs.help.

> Maybe this is a silly question, but why are some of the programs invoked
> different than others?

Because the shell has features ready for our use that would be a
wasted effort to re-implement in Lisp or C. E.g., complex
redirection, pipes, etc.

> PS: Here is a small docfix patch for process.c for review:

This is obviously correct, so please commit it on the emacs-23
branch.

> +PROGRAM is the program file name. It is searched for in EXEC-PATH. If

"PATH" is a literal name of an environment variable, that's why it is
in caps. But `exec-path' is spelled in lower case, so please don't
up-case it here. Also, please enclose in quotes, so it produces a
link in Emacs. I would even say


It is searched for in `exec-path' (which see).

Thanks.


0 new messages