Writing Dart? Check out Dart Code, my Dart extension for Visual Studio Code!

I recently picked up a Chromebook (a Dell Chromebook 11) and hoped to do a a little bit of hacking on Dart with it. Out-of-the-box the Chromebook can’t run native Dart code (as command line, nor in the browser), so you’re limited to web-based apps using Chrome Dev Editor (which is rather slow at compiling Dart in its JavaScript form).

In order to get around this, many people install Linux (usually Ubuntu via something like Crouton) but I didn’t want to do this because I don’t really like Ubuntu, and it seemed like quite an overhead just to run the (fairly light) Dart VM!

So, when my (replacement!) Chromebook (my 3rd in two weeks!) turned up today; I thought I’d see if the Dart VM would work in Chrome OS’s Developer Mode without having to resort to Linux.

It turned out to actually be pretty simple; and it might be even simpler to someone that understands Linux better than I do! The steps I followed are below. If anyone can improve these; please do post in the comments so I can update them. The editing of the bash_profile is a bit clunky (mainly because I don’t know vi; and I didn’t want to use another Chrome extension just to edit the file!) and I don’t really understand why I need to remount.

  1. Enable developer mode
    • WARNING: This will delete all of your locally stored data!
    • Every time you boot your device in this mode, you will get a scary splash screen and have to press Ctrl+D not to reset your device
  2. Download the Dart SDK to your Downloads folder
    • I picked the 64bit version for my Dell Chromebook 11; some Chromebooks might require the 32 bit version
  3. Unzip the SDK to your downloads folder
    • I put this at ~/Downloads/dart-sdk/
  4. Switch to the terminal window by pressing Ctrl+Alt+=>
    • (=> being the forward button where F2 would normally be)
  5. Run chmod +x ~/Downloads/dart-sdk/bin/dart
    • This will mark dart as executable
  6. Run chmod +x ~/Downloads/dart-sdk/bin/pub
    • This will mark pub as executable
  7. Run echo "sudo mount -i -o remount,exec /home/chronos/user/" >> ~/.bash_profile
    • I’m not a Linux guy; but this seems to be required to allow you to execute anything on this drive
    • Without this, you’ll get Permission denied trying to execute anything
  8. Run echo "PATH=\$PATH:~/Downloads/dart-sdk/bin/" >> ~/.bash_profile
    • This adds the Dart bin folder to your path so you can just type dart without the full path
  9. Reboot your Chromebook
    • This isn’t strictly required, you could just re-run .bash_profile, but it’s a good way to ensure it works after a reboot

Now when you want to run dart, you can do it from the normal browser-based shell!

  1. Press Ctrl + Alt + T to open a the ChromeOS Terminal
  2. Type shell to switch to the proper shell
  3. Type dart or pub to execute dart/pub

Here’s a screenshot showing it works on my Chromebook; I’m using Chrome Dev Editor for the Dart editing, and executing the tests in the shell. You can run pub serve this way and hit up http://localhost:8080/ in the browser for web apps (which I suspect will compile much quicker than the Chrome Dev Editor version).

Dart VM on Chromebook in Developer Mode

If you’re interested in a Chromebook; don’t forget to take a look at Chromebook Comparison Chart! :)