[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23186: 25.0.92; Tramp: Windows does not always set COMSPEC, tramp bl

From: Jerry Asher
Subject: bug#23186: 25.0.92; Tramp: Windows does not always set COMSPEC, tramp blows up in a string-match
Date: Sat, 2 Apr 2016 09:06:57 -0700

--text follows this line--

I started the 64 bit version of windows emacs from a shortcut on my taskbar. I
created the shortcut a few minutes ago by running emacs from the command
line, then pinning the shortcut. (There is a big caveat and I'll discuss
that at the end.)

Starting emacs up in restoring my desktop it loaded a python file. That
python file triggered python mode. Somewhere in there, ...

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("cmd\\.exe" nil)
  (if (string-match "cmd\\.exe" tramp-encoding-shell) "/c" "-c")
  eval((if (string-match "cmd\\.exe" tramp-encoding-shell) "/c" "-c"))
  custom-initialize-reset(tramp-encoding-command-switch (if (string-match "cmd\\.exe" tramp-encoding-shell) "/c" "-c"))
  custom-declare-variable(tramp-encoding-command-switch (if (string-match "cmd\\.exe" tramp-encoding-shell) "/c" "-c") "Use this switch together with `tramp-encoding-shell' for local commands.\nSee the variable `tramp-encoding-shell' for more information." :group tramp :type string)
  byte-code("\300\301!\210\302\303\304\305\306\307\306\310\311\312\313\314& \210\315\316\317\320\306\303\321\322& \210\315\323\324\325\306\303\321\326& \210\327\330!\203:

I believe the problem is in tramp.el which assumes that COMSPEC has been set.

(defcustom tramp-encoding-shell
  (if (memq system-type '(windows-nt))
      (getenv "COMSPEC")

The problem is that Windows can sometimes (see caveat below) start emacs such that COMSPEC is not defined.

I think perhaps a fix would be something along the lines of:

(defcustom tramp-encoding-shell
  (if (memq system-type '(windows-nt))
      (or (getenv "COMSPEC")
          (concat (getenv "systemroot") "\\system32\\cmd.exe"))

I'm not a windows developer, but it seems that modulo the systemroot, the system32\cmd.exe path is always (?) the right path.

So here's the caveat, I have poked the emacs.exe image so that it does not start as a console app, but so that it starts as a windows app. Now, I am not a windows developer, I do not know that this is why COMSPEC has not been set, but boy, it's got to be, right? ?

For more on how to poke the emacs.exe image to start as a windows app, see here https://github.com/jerryasher/consoleAppToWin basically, doing so seems to make both ntemacs and cygwin emacs run a bit nicer, and so far, this is the only issue I've seen crop up.

Now, you might reasonably claim that since I am starting up emacs in a very non-standard unsupported manner, the issue is totally mine and no fix is necessary. And there is some logic to that.

Regardless, I would say the assumption that COMSPEC is always set and so therefore if it fails it is okay to assign nil to tramp-encoding-shell knowing that later on it will be in a string-match is problematic in and of itself. 

But I've seen other users report the basic cmd.exe tramp-encoding-shell string match problem, see:


I don't know that my fix would fix those issues as well, but those issues point to a basic problem where tramp-encoding-shell is set to nil and then later compared in string-match.

So why not assign tramp-encoding-shell a default that will probably work instead?


Jerry Asher

In GNU Emacs (x86_64-w64-mingw32)
 of 2016-03-03 built on KAEL
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Configured using:
 'configure --prefix=/tmp/emacs --without-imagemagick 'CFLAGS=-O2
 -fomit-frame-pointer -g0''

Configured features:

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark saved where search started
Mark set
Unable to load color "peach"
Mark set [3 times]
Mark saved where search started [2 times]
Unable to load color "peach" [2 times]

Load-path shadows:
c:/Users/Jerry/.emacs.d/user-library/loaddefs hides c:/gnu/emacs-bin-w64-25.0.92-O2/emacs/share/emacs/25.0.92/lisp/loaddefs
c:/Users/Jerry/Dropbox/elpa/seq-2.15/seq hides c:/gnu/emacs-bin-w64-25.0.92-O2/emacs/share/emacs/25.0.92/lisp/emacs-lisp/seq
c:/gnu/emacs-bin-w64-25.0.92-O2/emacs/share/emacs/25.0.92/lisp/emacs-lisp/cl-generic hides c:/Users/Jerry/Dropbox/elpa/cl-generic-0.2/cl-generic

(shadow sort mail-extr emacsbug message rfc822 mml mml-sec epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils thingatpt find-or-tag
find-func dired-aux dired misearch multi-isearch vc vc-dispatcher vc-git
diff-mode easy-mmode warnings tramp-compat auth-source gnus-util mm-util
help-fns mail-prsvr password-cache tramp-loaddefs trampver ucs-normalize
shell pcomplete format-spec advice json map ido seq seq-25 grep compile
files-x etags xref project eieio byte-opt bytecomp byte-compile cl-extra
help-mode cconv eieio-core cus-edit wid-edit projectile-init
paredit-init package-sync-init nssh-mode-init neotree-init
multiple-cursor-init modeline-tweaks markdown-init magit-init
_javascript_-init find-or-tag-init expand-region-init edmacro kmacro
eldoc-init dired-init dev-requires desktop-init cygwin-init cygwin-mount
ange-ftp comint ansi-color ring basic-defuns.el cl-seq cl-macs gv
cl-loaddefs pcase cl-lib amazon-tweaks update-auto-loads utf-coding
required-libraries print-list key-bindings finder-inf slime-autoloads
info package easymenu epg-config time cus-start cus-load time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table w32-win w32-vars
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
w32notify dbusbind w32 multi-tty make-network-process emacs)

Memory information:
((conses 16 369391 18287)
 (symbols 56 30368 0)
 (miscs 48 160 430)
 (strings 32 54134 10687)
 (string-bytes 1 1555262)
 (vectors 16 45846)
 (vector-slots 8 806255 5532)
 (floats 8 306 365)
 (intervals 56 11467 2656)
 (buffers 976 28))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]