About Emacs 25 in WSL

With Windows 10, Microsoft offers a ‘Windows Subsystem for Linux (WSL)’ that runs a BASH Shell and quite a few classic Linux/Unix Tools, among them Emacs.

By default its based on an Ubuntu Image from Canonical, but for Experts there is a choice between 3 distros.

WSL is working quite well, but still considered Beta. Without some excellent Blog posts I would not have been able to successfully install (and use and update) Emacs 25. So here is the recipe (and the links) I used.

Activate WSL

Use this MSN Installation Guide:

Check OS Type and Build of you System, there are minimal requirements. You need to activate developer mode. There is a choice between Linux distros.

In case you have forgotten:

Install a graphical Linux environment

Although WSL is geared only towards Linux commandline tools, and Emacs is run as ‘emacs -nw’, you will need this for a workaround that enables you to use the Emacs package manager.

Follow the instructions on this page:

The X Server for Windows is downloaded here:

and installed by executing the installer like any other Windows program.

Most likely, you will get (DBus) errors (like I did) when trying XFCE4 with VcXsrv, i.e. by doing XLaunch (starting the X Server from the Windows Icon) and then calling ‘xfce4-session’ on the BASH command line.

Therefore you need to follow points 2 and 3 of the instructions on this page:

DISCLAIMER: doing point 3 (fixing dbus) is entirely at you own risk! It worked for me, but in the comment section of the linked page, one commenter reports that WLAN stopped working and he had to reinstall Windows 10 after this.

At the time of this writing, you need all this to make the Emacs package manager work. Running the installed Emacs 25 as -nw works just fine without X environment, but then you have to figure out yourself how to get your favorite packages.

Install Emacs 25

Follow the instructions on this page (a big THANKS to SolarianProgrammer for his excellents Blog Posts):

With the preparations above, I have

Funny enough, the graphical Emacs only accepted keyboard input ‘M-x’ after I once opened the Menu with F10 or so …

Furthermore, one has to answer a prompt where to put the ELPA directory. I’m not yet settled on this decision, since this is a critical point (accidentally editing Linux files with Windows Tools might corrupt the whole system, its recommended to make those files (maybe edited by both systems) Windows files under /mnt or so (see last paragraph of the installation guide:

Fix /dev/tty problem

If “sudo emacs -nw” works, but “emacs -nw” results in:

“emacs: Could not open file: /dev/tty”

this workaround (as discovered here too should help:

“sudo chmod go+rw /dev/tty”

DISCLAIMER: It’s left to your own judgement if this opens any security issues or not (I don’t know).