code

Git and Node in a Chromebook, Without Crouton and Linux


Note: I don’t post a lot about technical things, but since I wrote this to remind myself how to get out of trouble, I may as well post it in case anyone else has the same problems.

I recently bought a Toshiba Chromebook. My laptop died, and I didn’t feel like giving Apple $1000+ right away; I mostly wanted something light to take to conferences and Tweet from (or so I thought) so I bought the cheapest one recommended by the Wirecutter. (It’s not as cheap as they say, btw, but poking around I didn’t find anything better in the price and weight range I was looking for.)

So that was fine, and I was playing around with it, and I thought, well come on, if I was running virtual environments on my 4G Mac Air, I should at least be able to use Git on this Chromebook, right? Even if I’m just making Reveal.js presentations, I’d like to be able to fetch them from Git.

And then down the rabbit hole.

I first read the Lifehacker article on installing Linux; what excited me more was the “Ultimate Guide” for web dev on Chromebook that reminded me I could have Node. But as it turned out Crouton wasn’t that exciting; yes, installing Git and Python were a breeze (see below) but trying to install Node I had to try to manually give myself writable root access and that went very downhill, very quickly.  The good news is that it’s pretty easy restore the entire Chrome OS from the web! And I now have a copy of said OS on a USB drive!

The bad news is, even after restoration the Crouton extension was giving my Chrome browser some bad juju by trying to connect to the now non-existent Linux environment. Chrome would then restart when it couldn’t connect, which was every 15 seconds or so.  For a while I played a fun little game where I’d try to reset  the Chrome settings before it shut down but eventually I wiped them on another computer, then reset everything on the Chromebook, which fixed the problem.

Update: it looks like there’s an easier way to install working Linux on ChromeOS, but I haven’t tried it yet.

I almost gave up, but I at least wanted Git, so I tried again. And in the meantime, I found out there were a LOT of people hacking their Chromebook to do web dev without installing Linux. And in the meantime I became intrigued with the idea of using Chromebook for development in part for Marxist reasons: if it’s really meant to be the cheapest option, why not see what it can do? Also, although it’s cool that you can have a Linux system and all, I was irritated at having to switch back and forth. So I resolved to stick to the operating system that was already there.

Here’s what worked for me:

  1. Put Chromebook in developer mode: Shift+Esc + “refresh key” which is sort of like F3), hit CTRL +D on first screen, agree to turn off OS verification by hitting Enter.
  2. Find “enable debugging features link”, which will give you writable root access without destroying your OS (so far). Click on it and say yes to all the vaguely threatening questions.
  3.  Go into the developer screen and set a password so you can use sudo.
  4. Open a Terminal window (CTRL + ALT + T) and type shell.
  5. Install Python via Anaconda (that link is to a really great video, and the same guy has videos about Django development and iPython on Chromebook).
  6. Install Git, which comes with the initial installation of Chromebrew. Configure Git (reminder the best docs are here).
  7. Install Node, which is the pain in the ass. (SEE UPDATE BELOW!!). DO NOT use Chromebrew for this; it’s buggy and won’t work out of the box, and its dependencies will mess up the Python path you’ve made with Anaconda. Looking back at several blog posts (like this one and this one) most agreed you could just download the source and copy it to /usr/bin. That wasn’t working for me; the durned machine couldn’t find the node no matter what I put on the path. So I used the instuctions for node and Linux, which suggested the nodejs.org tarball distributions.  Inspired by what Anaconda did, I untarred it to /usr/local (don’t bother with adding XZ, just use tar -xvfJ on .xz files. I still had to add /usr/local/node/bin to the PATH, but it finally worked.

Update on Node:

I just found this post on installing NVM from source and it seems to work well and be less of a pain in the butt (especially if you discover, as I did, that you need a pinned version of node for something).  Note that you’ll need to sudo crew remove readline before installing; for some reason, Chromebrew messes up bash’s ability to read lines when using wget and curl.