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#23186: 25.0.92; Tramp: Windows does not always set COMSPEC, tramp blows up in a string-match Date: Sun, 03 Apr 2016 17:51:58 +0300 Message-ID: <83egamrbht.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1459695212 5881 80.91.229.3 (3 Apr 2016 14:53:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Apr 2016 14:53:32 +0000 (UTC) Cc: 23186@debbugs.gnu.org To: Jerry Asher Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 03 16:53:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1amjOp-0007CC-5Z for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Apr 2016 16:53:11 +0200 Original-Received: from localhost ([::1]:53762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amjOo-00055t-Bw for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Apr 2016 10:53:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amjOk-00055g-HE for bug-gnu-emacs@gnu.org; Sun, 03 Apr 2016 10:53:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amjOg-0000N1-Gq for bug-gnu-emacs@gnu.org; Sun, 03 Apr 2016 10:53:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amjOg-0000Mv-Co for bug-gnu-emacs@gnu.org; Sun, 03 Apr 2016 10:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1amjOg-0006qx-7k for bug-gnu-emacs@gnu.org; Sun, 03 Apr 2016 10:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Apr 2016 14:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23186 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23186-submit@debbugs.gnu.org id=B23186.145969515726311 (code B ref 23186); Sun, 03 Apr 2016 14:53:02 +0000 Original-Received: (at 23186) by debbugs.gnu.org; 3 Apr 2016 14:52:37 +0000 Original-Received: from localhost ([127.0.0.1]:50079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amjOH-0006qJ-JH for submit@debbugs.gnu.org; Sun, 03 Apr 2016 10:52:37 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amjOG-0006q7-1X for 23186@debbugs.gnu.org; Sun, 03 Apr 2016 10:52:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amjO6-0000C0-R3 for 23186@debbugs.gnu.org; Sun, 03 Apr 2016 10:52:30 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amjO6-0000Bw-NP; Sun, 03 Apr 2016 10:52:26 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3062 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1amjO5-0006jU-VO; Sun, 03 Apr 2016 10:52:26 -0400 In-reply-to: (message from Jerry Asher on Sat, 2 Apr 2016 09:06:57 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115929 Archived-At: > From: Jerry Asher > Date: Sat, 2 Apr 2016 09:06:57 -0700 > > The problem is that Windows can sometimes (see caveat below) start emacs such that COMSPEC is not defined. (The caveat being that the OP poked the PE headers of the Emacs binary to change its subsystem from 'console' to 'windows'.) FWIW, I cannot reproduce this problem. I've compiled a simple Windows GUI program that calls 'getenv', and it can access the COMSPEC variable without any trouble. I also used 'objcopy' to change the subsystem of the Emacs executable to 'windows' (which should have the same effect as what the OP did with a Python script), and the resulting executable does have COMSPEC in the environment when it starts. So I'm quite sure some other factor is at work here, most probably something in the user customizations. Looking at the value of process-environment after starting "emacs -Q" should be the first step for investigating the reasons for this behavior. If COMSPEC is not there in "emacs -Q", the next step is to describe the local configuration with system shells; if it is, look at your customizations in ~/.emacs and elsewhere. > Once more, I am not a windows developer, you are the maintainer, I have reported a bug, a bug felt not just by me but by many others, the current code, which sets it to NIL is 10,000% guaranteed to be wrong, since you REJECTED my proposed suggestion which would seem to work in most cases and be a great place to start, > > Here are a list of many other people who see this bug: > https://www.google.com/search?q=emacs+cmd.exe+tramp-encoding-shell+string-match The relevant hits of this Google search seems to point to just 2 reports, both of them look like they are related to magit. (Another report, where it turns out the user tried to use PowerShell as the system shell, can be disregarded as a situation that will never work on Windows without a lot of tinkering.) I didn't find any such issue in the magit issue tracker, so I'm not sure what's going on there. I suspect something related to the local setup with shells, perhaps, or maybe something related to Python mode. In any case, these reports don't seem to provide any useful information about the reason for the problem, as they all end in the user using the Tramp customizations to set tramp-encoding-shell directly, which btw is an okay solution, it just cannot be used in the default value of the defcustom, for the reasons explained up-thread. Last, but not least: COMSPEC is used in Emacs by more than just Tramp. For example, using M-! etc. to run commands that require a shell will not work without COMSPEC in the environment, because cmdproxy.exe uses the same method to find cmd.exe that Tramp does, and will fail if it cannot find it. So the Tramp problem is just the tip of a rather large iceberg. To summarize: . making Emacs a GUI app doesn't in itself interfere with COMSPEC . without COMSPEC in the environment many other Emacs features will fail . more information about the OP's setup is required to understand the reason(s) for the problem