When I run M-x term on the Windows version of Emacs, I am prompted to run C:/Program Files/emacs/libexec/emacs/25.1/x86_64-w64-mingw32/cmdproxy.exe

New versions of Windows 10 have the Linux subsystem and its shell (which is installed at C:\Windows\System32\bash.exe ~).

Is it possible to use this executable as the shell in Emacs?

I tried just pasting that path into the Run Program: path but I get the: Spawning child process error.

Is it possible to use this shell instead on Windows Emacs?

  • Are you able to use the Windows bash subsystem independently from Emacs? I think that's the first step as there is some configuration required (I believe, may have changed in more recent Win10 versions).
    – glucas
    Commented Nov 15, 2017 at 16:04
  • Yes. Ubuntu, on Windows 10 runs as a separate program. In fact, I can't run it from within emacs
    – Startec
    Commented Nov 16, 2017 at 8:06
  • Related to stackoverflow.com/questions/42346758/…
    – jmlorenzi
    Commented Aug 17, 2018 at 9:44

5 Answers 5


In my .emacs I first define a function like so

(defun my-bash-on-windows-shell ()
  (let ((explicit-shell-file-name "C:/Windows/System32/bash.exe"))

and I call at the bottom using:


Note that Emacs shell mode does not handle the default colored prompt very well, however changing my PS1 to:

PS1='\u@\h:\w\$ '

in my ~/.bashrc gave me a nice readable prompt.

  • I like this answer. However, I have noticed that after I kill the shell running the instance of Bash with exit then Ctl-x-k I can't open Bash again. The shell is empty and any input is just echoed back to the screen. Do have you this issue?
    – Startec
    Commented Apr 15, 2018 at 23:22
  • I've not noticed this, although I did do something slightly different - "(global-set-key [f9] 'my-bash-on-windows-shell)". I can type "exit" and the bash shall and restart it via F9 whenever needed. Commented Mar 4, 2019 at 17:35
  • One other caveat to get this working - on a 64-bit version of Windows 10, the 64-bit version of Emacs must be installed (if you're using the Chocolatey package manager then "choco install emacs" will work just fine). Some other emacs Windows builds out there are 32-bit, which won't allow this to work. Commented Mar 7, 2019 at 18:01
  • The .emacs configuration can be simplified to a single line (no function needed): "(setq explicit-shell-file-name "C:/Windows/System32/bash.exe")". M-x shell will then open bash instead of cmd.exe. I also found I had to update the prompt (PS1) for reliability.
    – Digicrat
    Commented Feb 22, 2020 at 4:16
  • That works for me. I recommend adding (interactive) as the second line of the defun to make the function a command (invokable from M-x).
    – Hugues
    Commented Mar 26, 2022 at 5:51

Windows Emacs cannot pass pseudo terminal device file to inferior bash/zsh, which is required for such shells to work interactively. There is a software called "fakecygpty" that provides pseudo terminal to Emacs inferior shell. (https://github.com/d5884/fakecygpty/) You can use that for Windows Emacs to work with MSYS2 shells.


I can get it to run M-x term using /windows/system32/bash.exe in Cygwin emacs-w32 (c: is my Cygwin root), but my issue is that the prompts are not displayed. Note that the environment looks almost exactly the same except extra directories /mnt/c/Windows/System32:/mnt/c/usr/local/bin:/mnt/c/bin:/mnt/c/lib/lapack in $PATH.

  • Does this answer the question? You don't really say how you "can get it to run...". Is the lack of prompts the only problem you see? A little more info/clarification could help.
    – Drew
    Commented Dec 26, 2017 at 21:42
  • Assuming that the question is about running bash.exe from the Windows version of emacs as opposed to a Cygwin version running on Windows, this doesn't seem to work - it just gives a "spawning child process invalid argument" error. Commented Mar 4, 2019 at 17:38

Windows 10 is supposed to have Bash built into it. If you are using Windows 10, I am sure that it is possible. https://msdn.microsoft.com/en-us/commandline/wsl/install_guide . It seems that there is also this if you are using other versions of Windows. https://sourceforge.net/projects/win-bash/?source=navbar . I have never used either of these, because I only use Windows at work. Good luck.

  • If you have an older version of Windows (pre 10) and Cygwin installed, then you may be able to adapt Bas Bossink's answer to invoke Cygwin instead of the WSL Bash prompt. I suspect the "win-bash" route would be less supported going forwards. Commented Mar 4, 2019 at 17:42

This doesn't answer the your exact question, but instead of that, I run Emacs in WSL+X11. Then you get everything you expect in Linux, including bash, and easy access to both your Windows and Linux drives.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.