Jeremy Kahn's Dev Blog

There's always a method to my madness.

Setting Up a Local Development Environment in Chrome OS

Cloud-only operating systems are a great option for most people. Web apps are slowly replacing native apps, and that trend is likely to continue. However, one type of user that will have a hard time migrating to the cloud is software developers. So many of our tools are local command line utlities, and they don’t really work in the context of a web application. I tend to treat UNIX as an IDE, and this methodology is at odds with the concept of cloud-only operating systems. I can’t see myself ever giving up tools like Vim or Git, or the simple elegance of piping the GNU Coreutils. Cloud-based IDEs like Cloud9 are cool, but they don’t give me the control that I get from a UNIX-like environment.

The common workaround for this is to SSH into a remote server via the browser, but I feel that this is a fundamentally flawed way to develop software. This approach requires you to buy and maintain two machines instead of one. More importantly, your productivity is limited by the quality of your internet connection. If you are in a coffee shop with spotty wifi or just enjoying a nice day in the park with your laptop, you won’t have easy access to your tools, if any at all.

I got a Chromebook over the holidays, and one of my concerns was that I wouldn’t be able to code on it effectively. I don’t really have much use for a laptop I can’t code with, so I started looking into ways to get Ubuntu loaded so I could enjoy my Linux tools unencumbered. I tried installing a Chromebook-optimized version of Ubuntu, but it was kind of buggy and I felt like I was missing the point of the Chromebook. I removed Ubuntu and instead tried Crouton, an awesome little tool written by David Schneider. Crouton makes it painless to install a chroot Ubuntu environment on Chrome OS. In other words, it creates an Ubuntu file system inside of Chrome OS’s file system and logs you in. When logged into the chroot, you are effectively running Ubuntu. It’s not virtualization, as Ubuntu has full access to your hardware resources, which can be a bad thing if you’re not careful. If you are careful, it works amazingly well. You can even run a Unity environment (or whatever GUI you want, Crouton lets you choose) and graphical applications. You can easily toggle between the Chrome OS and Ubuntu environments with a keyboard combination. What really matters is that you can run OpenSSH and easily interact with it from Chrome, even when you are offline.

This post serves as a guide for two things: Setting up the basic chroot environment with Crouton, and some setup I needed to perform in order to get some development tools running. There were a few issues that needed to be worked out because this is admittedly a backwards way to do things, and the Ubuntu environment installed by Crouton is a little bare-bones.

Getting started with Crouton

The first thing to do is boot the Chromebook into Developer Mode. Doing this will wipe the device, but that doesn’t really matter because everything is backed up to the cloud and gets synced back down when you log in. This is the process I had to follow for my model, and yours may be a little different - just Google for it. You don’t need to worry about setting up the firmware to boot from USB. Once you are in Developer Mode, sign in and hit Ctrl + Alt + T to fire up the shell. Type shell to be dropped into a BASH environment. At this point you need to follow the directions in Crouton’s README, but here’s a quick rundown of what you need to do in the shell we just opened:

1
sudo sh -e ~/Downloads/crouton -t unity

Go for a walk at this point - this will download about 700 MB of files. Once the process is complete, you will be prompted for the root user name password. Enter that, a few other bits of user info, and you’re done! Since we installed Unity, we can fire that up with:

1
2
# The `-b` backgrounds the process.  You can omit it.
sudo startunity -b

You can switch between the Chrome OS and Ubuntu environments with ctrl + alt + shift + F1 (the “back” button) and ctrl + alt + shift + F2 (forward), respectively.

That’s it! Now you can run Ubuntu apps inside of Chrome OS.

Setting up a development environment

The previous section was for setting up an Ubuntu chroot, this section is for setting up some tools that are useful for web development.

Git

You need Git. ‘Nuff said.

1
sudo apt-get install git

Vim with Ruby support

Command-T, a Vim plugin I use, depends on Ruby support. Because of this, I needed to compile Vim with Ruby support enabled. The Ubuntu chroot that Crouton installed lacks a few of the dependencies that a Ruby-enabled Vim requires, so I had to install those myself:

1
sudo apt-get install libncurses5-dev ruby-dev

From here I followed this guide written by Krešimir Bojčić , but here’s the part that actually gets and compiles the source code into an executable:

1
2
3
4
5
6
7
8
9
10
11
12
# Vim is in a Mercurial repository.
sudo apt-get install mercurial

hg clone https://vim.googlecode.com/hg/ ~/vim
cd ~/vim
hg update -C v7-3-154
./configure --with-features=huge  --disable-largefile \
            --enable-perlinterp   --enable-pythoninterp \
            --enable-rubyinterp   --enable-gui=gtk2 \

make
sudo make install

Now your Vim has Ruby support!

OpenSSH

Another critical tool for me is OpenSSH, because I like to SSH into my Ubuntu environment from Chrome and not deal with Unity any more than I have to. The easiest way to do this is to install tasksel and install OpenSSH from there:

1
2
sudo apt-get install tasksel
sudo tasksel

tasksel gives you a UI to select a number of packages you’d like to install, including OpenSSH. You can also easily install a LAMP stack from this UI, if you’d like.

Node

Yup, you can run NodeJS from Chrome OS. It’s as simple as:

1
sudo apt-get install nodejs npm

Full-stack development for $250

The Chromebook is an amazing little device. By running an Ubuntu chroot, you have all the tools you need to build a web project from scratch, and probably a lot more. Keep in mind that it has an ARM instruction set, so some programs may not work (or at least need to be compiled from source). I haven’t had any hangups that I couldn’t fix, however. Why is this worth the trouble? Personally, I just like little computers. It’s also great to have a SSD-powered laptop that has no moving parts - not even a fan. A soft benefit of having such an inexpensive device is the peace of mind of not lugging around a $2000+ laptop with you to the coffee shop. The 11-inch screen is reasonably comfortable to code on and the battery life is great. The Chromebook feels like a poor man’s MacBook Air, and with a full-featured local development environment, I can safely depend on it wherever I go.