I’ve had the Linux Subsystem for Windows enabled for quite a while during the time it was in Beta. With the release of the Fall Creators Update, I ended up redoing my setup from scratch. As usual I grabbed Emacs and a bunch of other packages and was initially disappointed that I was looking at a text-mode only Emacs. That might have something to do with the lack of an X Server…
For a free X Server on Windows, I had a choice of Xming and VcXsrv. I used Xming a long time ago and I’m happy to pay for software, but decided to go with something free for this initial proof of concept. Plus, I was curious about VcXsrv, so I picked that. I really like that its installer includes everything I needed right out of the box, including the fonts.
So, after a brief install and an ’export DISPLAY=localhost:0’ on the Ubuntu command line, we have an Ubuntu Emacs running on in a window on my Windows desktop without using a third-party VM:
So far, so good, but given that the Ubuntu subsystem on Windows is running Ubuntu 16.04 LTS, what we have is an older version of Emacs, specifically Emacs 24.5:
Clearly, that won’t do. I was also rather curious if the Ubuntu subsystem was good enough so my previous instructions on building GNU Emacs on Ubuntu 16.04 would work. Let’s go find out!
First, it’s time to install the build dependencies for Emacs 24:
timo@odie-win8:~/hg-repos/lonecpp-wp$ sudo apt-get build-dep emacs24 [sudo] password for timo: Reading package lists... Done E: You must put some 'source' URIs in your sources.list
Ah well, not entirely unexpected - the source repository isn’t enabled. That’s easy, but I normally enable it from the GUI so I first had to figure out how to enable it from the command line. Which again turns out to be easy, all I have to do is edit /etc/apt/sources.list and uncomment the deb-src lines. Job done. I just uncommented the deb-src entries for the main, restricted, universe and multiverse repositories. That might have been more than I needed but should work fine. Also, don’t forget to run `sudo apt update` after enabling the repos!
Now I can install the build dependencies again:
sudo apt build-dep emacs24
… and after a long download of the usual plethora of packages, I have everything in place to build Emacs from source. Sticking to my usual approach of just using a current release version, I tried building Emacs 25.3 first.
Doing the usual configure/make/make install dance didn’t get me very far, unfortunately:
Dumping under the name emacs ************************************************** Warning: Your system has a gap between BSS and the heap (20719407 bytes). This usually means that exec-shield or something similar is in effect. The dump may fail because of this. See the section about exec-shield in etc/PROBLEMS for more information. ************************************************** Makefile:736: recipe for target 'bootstrap-emacs' failed make: *** [bootstrap-emacs] Segmentation fault (core dumped) make: Leaving directory '/home/timo/build/emacs-25.3/src' Makefile:398: recipe for target 'src' failed make: *** [src] Error 2
I haven’t had much time to research this issue yet, but it looks like I might have hit a quirk of the Linux Subsystem on Windows that isn’t necessarily present in Ubuntu 16.04 LTS.
As a quick test, I tried to build a different version. I picked Emacs pretest 26.0.90 as a suitable version - hey, nothing like a bit of living on the edge. To keep everything inside the Ubuntu Linux subsystem, I pulled it down using wget and ran through the usual sequence of configure/make/make install:
wget ftp://alpha.gnu.org/gnu/emacs/pretest/emacs-26.0.90.tar.xz cd build-dir tar xvJf emacs-26.0.90.tar.xz cd emacs-26.0.90 ./configure --prefix=$HOME/local make && make install
The surprisingly good news were that pretest built fine - no core dumps when dumping emacs- and a quick check confirmed that it was running fine in a terminal window. Yay.
Time to push boundaries again, especially as the Fall Creators Update Linux Subsystem for Windows does not support X/GUI applications as per Microsoft. Unfortunately with this build, attempting to run the resulting binary as a GUI executable produced a bunch of errors and an empty window that only contained the menu bar.
~/local/bin/emacs (emacs:15590): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkWidget' (emacs:15590): Gtk-CRITICAL **: gtk_widget_hide: assertion 'GTK_IS_WIDGET (widget)' (emacs:15590): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GObject' (emacs:15590): GLib-GObject-CRITICAL **: g_object_get_data: assertion 'G_IS_OBJECT (object)' failed
I guess that might have been an attempt to push things a little too far. After all, Microsoft says that X/GUI apps aren’t supposed to work, so the simple fact that I was able to get the stock Emacs 24.5 working was a big surprise
I may try to figure out what’s causing these errors and see if I can get Emacs pretest working with X windows as well, if I can find the spare time…