My programming ramblings

Emacs 25 on Windows Subsystem for Linux

Posted on May 18, 2017 by Paul

Recently, a reader of this blog asked me about using Emacs under Windows Subsystem for Linux. According to the WSL documentation, Emacs, Vim and other Linux applications that run from console should work just fine. Turns out that the situation is a bit more complex. At the time of this writing, Emacs works fine for normal text editing. But, when you try to install a new package directly from Emacs, the program is stopped and sent to background and doesn’t seem to be able to cleanly recover when you use fg. From a practical point of view, this makes Emacs, under WSL, useless if you need to install any package that is not built in.

Fortunately, there is a workaround for the above bug and I will show you in this post how to avoid the problem. As far as I know, Emacs under WSL seems to work without a problem only if you install a desktop environment like Xfce 4. The idea is to use the GUI version of Emacs when you need to install a package. For normal editing, you can use Emacs from the WSL console.

If you are satisfied with the default Emacs configuration, this is all you need to do. Emacs will work just fine for normal text editing from the WSL console:

1 emacs -nw

this is what I see on my machine:

I assume that you want to install at least a few packages in Emacs to make your life easier. If you try to list, M-x list-packages, or install packages directly from the WSL console, you will hit the bug I’ve mentioned at the beginning of this article.

Use XLaunch to start an X server (see my previous article). You can find Emacs in Applications → Development:

At this point, you can edit .emacs.d to fit your needs and install any package you need. Once you’ve finished, you can close the X server and use Emacs from a normal WSL console.

If you want to learn more about the Linux command-line applications, I would recommend reading The Linux Command Line by William E.Shotts Jr.

Disclaimer:All data and information provided on this site is for informational purposes only. solarianprogrammer.com makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis. solarianprogrammer.com does not collect any personal information about its visitors except that which they provide voluntarily when leaving comments. This information will never be disclosed to any third party for any purpose. Some of the links contained within this site have my referral id, which provides me with a small commission for each sale. Thank you for understanding.