Web development on a Chromebook. Is it possible? Even if its possible, does it work well? It does! I develop web applications, mainly using Ruby on Rails on my Chromebook. I used to use to 15 inch MacBook Pro, but since I travel almost every month, after a while, lugging my macbook around was a real pain in the back. For the last year or so I've been using an Asus C302A Flip Chromebook. At first, I wasn't sure the Chromebook was going to be able to cope with web app development using Ruby on Rails, but I was pleasantly surprised.
In this post I'm going to document how I set up ubuntu on my Chromebook for local web development. Please note that I've already put my Chromebook in developer mode, installed Crouton and created an ubuntu chroot. If you haven't done it here's a guide on installing crouton and chroots on your chromebook.
Once you're all set up, follow these steps to set up Ruby on Rails on your new Ubuntu Chroot.
- Open Chrome
- Press CTRL + ALT + T
sudo enter-chroot -n ubunutu
The '-n' let's you pass a name to your chroot. Hopefully you named your chroot. If you only have one chroot, you can skip the '-n ubuntu'. If you have multiple chroots, and you didn't name yours then the default name will be the release name, something like 'xenial'.
Congratulations, you're now logged in to your virtual ubuntu machine. Now for the fun part.
sudo apt-get install git
sudo apt-get install curl
sudo curl -sSL https://get.rvm.io | bash -s stable
Ah, I got a failure. Something to do with GPG keys.
sudo curl -sSL https://rvm.io/mpapis.asc | gpg --import -
OK now rerun the previous curl command to get rvm. You should see a success message like this:
Installation of RVM in /home/user/.rvm/ is almost complete:
* To start using RVM you need to run `source /home/user/.rvm/scripts/rvm` or source ~/.rvm/scripts/rvm
in all your open shell windows, in rare cases you need to reopen all shell windows.
Let's check we have the latest version installed.
rvm get stable
Now we need to get the system ready for Ruby
What ruby versions can we install? Let's check.
rvm list rubies
2.4 is the latest. If I'm not mistaken the app I want to work on runs on 2.2, so I'm going to install that.
rvm install 2.2
Wait a while….
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-linux]
To avoid conflicts between ruby versions, we'll create a gemset to use with this ruby version.
rvm use email@example.com_default --create --default
Using /home/chirag/.rvm/gems/ruby-2.2.7 with gemset r2.2_default
Before we install rails, we should tell rubygems not to create any documentation. Use your text editor to edit the file. I'm using VIM.
Add the following two lines in the file and save.
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
Now you can install rails. I'm using 4.2.10
gem install rails --version 4.0.8
We need to perform some one time set up if this is the first time you're using git.
git config --global user.name "Your Full Name"
git config --global user.email firstname.lastname@example.org
git config --global alias.co checkout
Once you're in a folder where you want to work
If you're working on code that's already on a repository
git remote add origin email@example.com:username/projectname.git
To use this we need to set up ssh keys for bitbucket.
ssh-keygen -f ~/.ssh/<bitbucketusername>
Paste the contents into bitbucket. Follow these instructions.
Now grab your repository. Use clone instead of pull as it will set up remote tracking.
git clone firstname.lastname@example.org:team/project.git
You should be ready to roll if you downloaded an existing rails project. Enjoy!