Hit Escape to see thumbnails of all slides | Elze Hamilton, January 5, 2015 | My website

Virtual machines, Vagrant and rails-dev-box

and how they make a developer's life easier

By Elze Hamilton / @elze

Some uses of virtual machines:

  • working with a non-Windows technology stack on a Windows machine

  • Installing the right versions of Ruby, Rails, or Python and its packages can be complicated on Windows, unlike on Mac or Unix machines

  • you want to experiment with new-to-you technologies without investing much time in setup and configuration

  • you want to have several versions of the programming language, framework, database, tools, for different projects on your computer
  • (e.g. Ruby 1.9 and Ruby 2.0, Python 2 and Python 3. One way to make different versions coexist on one computer is to have them on separate virtual machines.)

What is Vagrant?

From vagrantup.com:

"Vagrant is a tool for building complete development environments"

(pretty vague)


"Create a single file for your project to describe the type of machine you want, the software that needs to be installed, and the way you want to access the machine. Store this file with your project code. Run a single command "vagrant up" and sit back as Vagrant puts together your complete development environment"

(that's more helpful)

How is Vagrant useful

The virtual machine that Vagrant brings up has access to the files on your main (physical) machine.

  • you can edit your files on your main machine using your favorite text editor or IDE.

  • when you start a web server on the virtual machine, you can access your app in the browser on your main machine.

I will demonstrate this in a minute.

Creating a Vagrant environment

the easy way

Get an already existing Vagrant file.

For example, rails-dev-box

Download it from


rails-dev-box is

... a Vagrant file plus a script to install all sorts of useful software on your virtual machine

(Don't be bothered by the rails-dev-box README page that says "this VM is not designed for Rails application development, only Rails core development." I haven't found a reason yet why its not good for Rails app development, and it is recommended by the RailsBridge workshop.)

Best of all, rails-dev-box is not just for Rails or Ruby!

You can install any programming language or framework on it -- Python, Node, you name it.

Brief overview of installation

1. Install VirtualBox -- the software that enables creation of virtual machines on your computer.

VirtualBox running(you don't need to launch VirtualBox when you install it. It's just a prerequisite for Vagrant. Install and forget it.)

2. Install Vagrant.

3. Launch Vagrant

  • Go to a command prompt

  • cd <path/to>/rails-dev-box (the directory where you downloaded rails-dev-box)

  • vagrant up

Vagrant installs all the software specified in the bootstrap.sh script

VirtualBox running

Once rails-dev-box is running:

  • vagrant ssh

  • cd /vagrant

  • Install Rails, or any language or framework you want: Python, Node, Java, etc.
  • (Ignore what rails-dev-box README page tells you about cloning Rails from Github. This is only for developers who want to work on Rails core. If you just want to develop Rails apps, install Rails the usual way, e.g. gem install rails.)

Now, a demo

In the live presentation there was a demo that

  • created a rails app in the virtual machine
  • showed that its files were accessible for editing on your main machine, outside Vagrant
  • started the rails web server on the virtual machine
  • went to the web server's URL, http://localhost:3000/, in the browser on your main machine and showed that you can test your app outside Vagrant