Running Sublime Text on a Raspberry Pi 2

I have this tendency to be persistent. Sometimes exceptionally so, and to lengths that border on the obssessive, especially when it comes to how technology should work.

Two years ago, I adopted Sublime Text 2 as my “non-vim” editor, and mostly stuck to it, even when it spontaneously combusted when trying to perform Clojure syntax highlighting.

But one of the things that annoyed me (ever since I got my ODROID-U2, in fact) was that it only ran on Intel hardware, even considering that an Ubuntu ARM build shouldn’t be significantly harder.

Two years hence, older and arguably not much wiser, I decided it was time to fix that – and here it is, running on a Raspberry Pi 2:

There’s hardly any magic involved – all you need to do is run Ubuntu (I’m using this community-maintained image, which is now my standard OS for it), download Sublime, unpack it and issue the following commands:

# add support for i386 binaries and user-level QEMU
$ sudo apt-get install qemu-user binfmt-support

# add extra repos for i386
# (I had these handy)
$ sudo tee /etc/apt/sources.list.d/i386.list 
deb trusty main restricted universe multiverse
deb trusty-updates main restricted universe multiverse
deb trusty-security main restricted universe multiverse
deb trusty-backports main restricted universe multiverse

# update your package list
$ sudo apt-get update

# install i386 versions of Sublime dependencies, including libc, X11, the works...
$ sudo apt-get install libc6:i386 libstdc++6:i386 libglib2.0-0:i386 libX11-6:i386 libpangocairo-1.0-0:i386 libgtk2.0-0:i386

# Run Sublime Text
$ qemu-i386 sublime_text 

And boom, you’re running Sublime Text 2 on a Raspberry Pi, with i386 code translated on the fly to ARMv7.

This will likely work for most other pre-packaged Linux binaries (as long as you install the right dependencies), and, with a fair amount of extra tweaking, will also let you run (some) Windows binaries.

Of course, even though this is possible, it is only barely usable on the Raspberry Pi 2 even considering its beefier CPU. But it does scratch my particular itch, and I can cross it out of my to-do list1.

I’ve yet to try it on my ODROID-U2 (which should be nearly twice as fast), but didn’t want to pollute that with a bunch of single-use Intel binaries2. But I’ve already built a working Docker container that runs on the Pi (one of the reasons I’m using Ubuntu on it is that Docker works great, provided you use armhf base images), and I’ll eventually find the time to test it there in earnest.

For real-life use, Caret (which runs perfectly well with Chromium, even on Raspbian) is a much better option – and one I definitely recommend if you need a coding editor, at least until the Sublime Text developers come to their senses and ship an ARM build.

Come on, guys, it can’t be that hard. Call it an alpha, or call me to help you set up a cross-compiling environment…

  1. You’d be surprised at the amount of stuff I think I ought to “fix” some day… ↩︎

  2. Although, to be honest, the prospect of being able to run WINE and Evernote on an ARM machine is tempting… ↩︎