`M-x term' with Emacs on MS Windows: error Spawning child process: invalid argument

fniessen picture fniessen · Nov 28, 2013 · Viewed 7k times · Source

whenever I try to launch M-x term from my Windows distribution of GNU Emacs, I get the error:

apply: Spawning child process: invalid argument

after accepting the default program to run (either "bash.exe" or "zsh.exe", from Cygwin, and present in my Windows PATH environment variable).

M-x shell does work with Zsh/Bash from Cygwin. But I'd like to use Term to get more features...

Any help?

Answer

Alex Vorobiev picture Alex Vorobiev · Dec 1, 2013

From my experience none of the terminal emulators in Emacs (term, ansi-term, multi-term) is supported under Windows. It looks like the main reason is all of them rely on low-level support for terminals (stty, etc) which is not provided by Windows. Trying to force Emacs to use, say, Cygwin bash by editing references to e.g. /bin/sh in term.el doesn't help either. It may work in Cygwin Emacs but I haven't used it in a long time because native W32 Emacs is so much better (for me). Shell mode works fine with either Cygwin bash or Windows cmd (via cmdproxy which is part of Emacs install). You can have support for ANSI colors if you do

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

I tried eshell many times but ended up using the shell mode with bash because I tend to use pipes and redirections a lot. Are there any particular applications that you would like to use that require full-featured terminal support? I was missing top at first but then I just started using M-x proced.

UPDATE: term, ansi-term, and multi-term do work in Cygwin emacs.