<jack>

If it’s too hard you’re doing it wrong.

Ruby 1.9 Development with Windows, VirtualBox, and Ubuntu

Posted at — Jun 20, 2009

Ruby is more at home on *nix than on Windows. This tutorial covers setting up a Windows machine as a VM host, installing an Ubuntu VM, building Ruby 1.9, and setting up file sharing between Windows and the VM.

First download and install VirtualBox. You should create a VM and mount the Ubuntu 9.04 server ISO in the CD drive. I used the 64-bit version. I experienced numerous random problems with the desktop edition, but the server edition worked well.

Before booting the VM for the first time we should set up the network the VM will use. VirtualBox has several different network options depending on what level of access is needed to and from the VM. In this case, I want complete inbound and outbound access to the VM. The network setup we will use is very simple, but it may not be secure outside of a trusted LAN. In the settings for the VM set the network adapter to bridged.

Boot the VM and install the OS. The network configuration will probably grab a DHCP address automatically, but we really want to assign a static IP so we can easily connect via SSH. Either cancel the network auto-detection or if you are not quick enough choose to go back when it asks you for a host name. Manually configure the network to use a static IP address (you might also want to add an entry to your hosts file on the Windows machine so you don’t have to remember the IP address). When it offers a list of servers to install choose SSH.

After the install completes we should be able to use SSH into our VM.

Before we do anything else we should setup version control for our VM’s /etc directory. This simple step can save much frustration down the road if we ever mess this VM up.

sudo aptitude install etckeeper
sudo etckeeper init
sudo etckeeper commit "initial import"

We could just install Ruby with aptitude and be done, but historically there have been issues especially with RubyGems so I prefer to compile from source. So we need to install the build tools and libraries Ruby will need.

sudo aptitude install build-essential libssl-dev libreadline5-dev zlib1g-dev

Next download, compile, and install the latest version of Ruby 1.9 (1.91.-p129 at the time this was written).

At this point we should have Ruby operational. However, we really want to be able to access our files transparently from Windows. So let’s setup SAMBA.

Now we need to configure our share. Edit /etc/samba/smb.conf.

Around the middle of the file we need to change the security option. Uncomment it and change it to share.

Then at the bottom add your share. force user and force group are needed to set the proper owner for any files created from Windows. Since I am using static IP assignments it is easy to only allow the host access to the file shares with hosts allow.

At this point we have a working Ubuntu Ruby 1.9 development environment that we can access from Windows.