rails/rails-dev-box
{ "createdAt": "2012-08-14T20:25:03Z", "defaultBranch": "master", "description": "A virtual machine for Ruby on Rails core development", "fullName": "rails/rails-dev-box", "homepage": null, "language": "Shell", "name": "rails-dev-box", "pushedAt": "2024-01-12T06:24:23Z", "stargazersCount": 2048, "topics": [], "updatedAt": "2025-11-19T13:07:10Z", "url": "https://github.com/rails/rails-dev-box"}A Virtual Machine for Ruby on Rails Core Development
Section titled “A Virtual Machine for Ruby on Rails Core Development”Introduction
Section titled “Introduction”Please note this VM is not designed for Rails application development, only Rails core development.
This project automates the setup of a development environment for working on Ruby on Rails itself. Use this virtual machine to work on a pull request with everything ready to hack and run the test suites.
Requirements
Section titled “Requirements”-
Install the
vagrant-vbguestplugin:vagrant plugin install vagrant-vbguest.
How To Build The Virtual Machine
Section titled “How To Build The Virtual Machine”Building the virtual machine is this easy:
host $ git clone https://github.com/rails/rails-dev-box.githost $ cd rails-dev-boxhost $ vagrant upThat’s it.
After the installation has finished, you can access the virtual machine with
host $ vagrant sshWelcome to Ubuntu 23.10 (GNU/Linux 6.5.0-14-generic x86_64)...vagrant@rails-dev-box:~$Port 3000 in the host computer is forwarded to port 3000 in the virtual machine. Thus, applications running in the virtual machine can be accessed via localhost:3000 in the host computer. Be sure the web server is bound to the IP 0.0.0.0, instead of 127.0.0.1, so it can access all interfaces:
bin/rails server -b 0.0.0.0RAM and CPUs
Section titled “RAM and CPUs”By default, the VM launches with 2 GB of RAM and 2 CPUs.
These can be overridden by setting the environment variables RAILS_DEV_BOX_RAM and RAILS_DEV_BOX_CPUS, respectively. Settings on VM creation don’t matter, the environment variables are checked each time the VM boots.
RAILS_DEV_BOX_RAM has to be expressed in megabytes, so configure 4096 if you want the VM to have 4 GB of RAM.
What’s In The Box
Section titled “What’s In The Box”-
Development tools
-
Git
-
Ruby 3.1
-
Bundler
-
SQLite3, MySQL, and Postgres
-
Databases and users needed to run the Active Record test suite
-
System dependencies for
nokogiri,sqlite3,mysql2, andpg -
Memcached
-
Redis
-
RabbitMQ
-
An ExecJS runtime
Recommended Workflow
Section titled “Recommended Workflow”The recommended workflow is
-
edit in the host computer and
-
test within the virtual machine.
Just clone your Rails fork into the rails-dev-box directory on the host computer:
host $ lsbootstrap.sh MIT-LICENSE README.md Vagrantfilehost $ git clone git@github.com:<your username>/rails.gitVagrant mounts that directory as /vagrant within the virtual machine:
vagrant@rails-dev-box:~$ ls /vagrantbootstrap.sh MIT-LICENSE rails README.md VagrantfileInstall gem dependencies in there:
vagrant@rails-dev-box:~$ cd /vagrant/railsvagrant@rails-dev-box:/vagrant/rails$ bundleWe are ready to go to edit in the host, and test in the virtual machine.
Please have a look at the Contributing to Ruby on Rails guide for tips on how to run test suites, how to generate an application that uses your local checkout of Rails, etc.
This workflow is convenient because in the host computer you normally have your editor of choice fine-tuned, Git configured, and SSH keys in place.
Virtual Machine Management
Section titled “Virtual Machine Management”When done just log out with ^D and suspend the virtual machine
host $ vagrant suspendthen, resume to hack again
host $ vagrant resumeRun
host $ vagrant haltto shutdown the virtual machine, and
host $ vagrant upto boot it again.
You can find out the state of a virtual machine anytime by invoking
host $ vagrant statusFinally, to completely wipe the virtual machine from the disk destroying all its contents:
host $ vagrant destroy # DANGER: all is gonePlease check the Vagrant documentation for more information on Vagrant.
Faster Rails test suites
Section titled “Faster Rails test suites”The default mechanism for sharing folders is convenient and works out the box in all Vagrant versions, but there are a couple of alternatives that are more performant.
Vagrant 1.5 implements a sharing mechanism based on rsync that dramatically improves read/write because files are actually stored in the guest. Just throw
config.vm.synced_folder '.', '/vagrant', type: 'rsync'to the Vagrantfile and either rsync manually with
vagrant rsyncor run
vagrant rsync-autofor automatic syncs. See the post linked above for details.
If you’re using Mac OS X or Linux you can increase the speed of Rails test suites with Vagrant’s NFS synced folders.
With an NFS server installed (already installed on Mac OS X), add the following to the Vagrantfile:
config.vm.synced_folder '.', '/vagrant', type: 'nfs'config.vm.network 'private_network', ip: '192.168.50.4' # ensure this is availableThen
host $ vagrant upPlease check the Vagrant documentation on NFS synced folders for more information.
Troubleshooting
Section titled “Troubleshooting”On vagrant up, it’s possible to get this error message:
The box 'ubuntu/yakkety64' could not be found orcould not be accessed in the remote catalog. If this is a privatebox on HashiCorp's Atlas, please verify you're logged in viavagrant login. Also, please double-check the name. The expandedURL and error message are shown below:
URL: ["https://atlas.hashicorp.com/ubuntu/yakkety64"]Error:And a known work-around (https://github.com/Varying-Vagrant-Vagrants/VVV/issues/354) can be:
sudo rm /opt/vagrant/embedded/bin/curlLicense
Section titled “License”Released under the MIT License, Copyright (c) 2012–ω Xavier Noria.