From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#7793: inconsistent behavior of exec-path Date: Thu, 06 Jan 2011 05:10:33 -0500 Message-ID: References: Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1294309454 22627 80.91.229.12 (6 Jan 2011 10:24:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 6 Jan 2011 10:24:14 +0000 (UTC) Cc: 7793@debbugs.gnu.org To: Sam Steingold Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 06 11:24:09 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pan0l-0006zy-Gt for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Jan 2011 11:24:03 +0100 Original-Received: from localhost ([127.0.0.1]:37729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pan0k-0004Nc-R7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Jan 2011 05:24:02 -0500 Original-Received: from [140.186.70.92] (port=57257 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pan0c-0004NR-8S for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2011 05:23:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pan0a-0000HT-Kh for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2011 05:23:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pan0a-0000HP-Hl for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2011 05:23:52 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PamhO-0004OF-GF; Thu, 06 Jan 2011 05:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Jan 2011 10:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7793 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7793-submit@debbugs.gnu.org id=B7793.129430820516829 (code B ref 7793); Thu, 06 Jan 2011 10:04:02 +0000 Original-Received: (at 7793) by debbugs.gnu.org; 6 Jan 2011 10:03:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pamgn-0004NO-3X for submit@debbugs.gnu.org; Thu, 06 Jan 2011 05:03:25 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pamgl-0004NB-3B for 7793@debbugs.gnu.org; Thu, 06 Jan 2011 05:03:23 -0500 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1Pamnh-0008P2-Io; Thu, 06 Jan 2011 05:10:33 -0500 In-reply-to: (message from Sam Steingold on Wed, 5 Jan 2011 18:07:48 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 06 Jan 2011 05:04:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:43142 Archived-At: > Date: Wed, 5 Jan 2011 18:07:48 -0500 > From: Sam Steingold > Cc: > > suppose you have two directories (A&B) which contain two different > executables with the same name (N). > e.g., find.exe(N) in both "c:/gnu/gnuwin32/bin"(A) and "c:/WINDOWS/system32"(B). > if A follows B in $PATH, then M-x shell-command will call A/N for N > even if I manually swap A & B in exec-path. You mean "iff", not "even if", right? Because if you do _not_ swap A and B in exec-path, I'd expect B/N to be invoked, since B precedes A in PATH. Am I missing something? > However, if I run rgrep in "emacs -q", it fails because by default B > is before A in PATH and exec-path; > while if I push A to the beginning of exec-path before the first > invocation of rgrep, rgrep will find and use the good N. I used to play such games with PATH and exec-path (and a few other related variables) inside Emacs, but then I grew older and wiser. Please consider taking advice of my gray hair: don't do that. Do _not_ have values of PATH, exec-path, process-environment, etc. that have the same directories in different order. That way lies madness, believe me. The reason for this is very basic, on Windows as on Unix: exec-path is used only for the program that Emacs invokes directly. If that program invokes other programs, it will look them up on PATH. So having conflicting orders in PATH and exec-path means that programs invoked through call-process and programs invoked through shell-command will be searched for using different order of directories. To get deterministic behavior out of this, you'd need to know, for every Emacs command, whether it uses the former or the latter, and even if you do, I don't think you will be able to set both PATH and exec-path correctly for all your use-cases (including all the bugs, misfeatures, and subtle incompatibilities of the Windows ports of GNU software). FWIW, I don't think the inconsistency that is the subject of this bug can be resolved in any reasonable way. The separation between exec-path and PATH is deliberate in Emacs, so setting one from the other will not DTRT at least for some use-cases. > this inconsistency is bad and together with bugs > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6784 > and > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7785 > is causing me much grief in my first encounter with windows in 4 years. I'm sorry about your trouble. To save some of it in the future, I'd suggest: . Put the GnuWin32 directory _before_ the Windows directories in PATH . If you need to use Cygwin executables in the same session as GnuWin32, decide on the order between them according to your needs; if you only use one or the other, throw together a bunch of batch files that reorder PATH for each one, and invoke the one you need when you need it (you can have a separate setting in each shell window) . Don't reshuffle exec-path and process-environment in your .emacs . If needed, and only as a last resort (if PATH reordering doesn't help), rename a few ported programs (e.g. find->gfind or date->gdate), so that Windows versions don't come in the way (you may need to customize a few variables if you do this, e.g. find-program for "gfind") I find this arrangement to be a much saner one, and it works very well for me for years.