CategoryWSL

About Emacs 25 in WSL

With Windows 10, Microsoft offers the ‘Windows Subsystem for Linux (WSL)’ that runs Linux binaries, including the BASH Shell, and emacs, natively on Windows.

You can install Linux distros from the Windows Store. Currently Ubuntu, openSUSE and SUSE Linux are available, with several other distros on the way. You can also install and run multiple distros side-by-side on the same machine, and you can use each distro’s package manager to install all your favorite tools and apps.

WSL is improving rapidly in terms of completeness and compatibility, though you may encounter the occasional issue, in which case, please search and (if not found) file an issue on the WSL team’s GitHub Issues Repo: https://github.com/microsoft/wsl.

Here is how I install emacs 25:

Install & Activate WSL

The official WSL Installation Guide: https://msdn.microsoft.com/commandline/wsl/install_guide

Check OS Type and Build of you System, there are minimal requirements. There is a choice between Linux distros.

Be sure to specify a non-su username and password when prompted - Linux usernames and password are separate from your Windows username and password.

Install a graphical Linux environment

Although only Linux commandline tools are officially supported on WSL many X applications work fine. In addition, you may want to install a Linux GUI/desktop, though this will require having all X applications in a dedicated toplevel window — follow the instructions on this page: https://solarianprogrammer.com/2017/04/16/windows-susbsystem-for-linux-xfce-4/

There are several X Servers for Windows, some of which include:

[The following is probably outdated with recent updates to WSL]

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. If so, follow points 2 and 3 of the instructions on this page:

https://www.reddit.com/r/Windows10/comments/4rsmzp/bash_on_windows_getting_dbus_and_x_server_working/

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):

https://solarianprogrammer.com/2017/05/18/emacs-windows-subsystem-linux/

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: https://msdn.microsoft.com/de-de/commandline/wsl/install_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 https://alexschroeder.ch/wiki/2015-09-18_Emacs_and_TTY) 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).