Ruby 1.9 Development with Windows, VirtualBox, and Ubuntu
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).
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p129.tar.gz tar xzf ruby-1.9.1-p129.tar.gz cd ruby-1.9.1-p129/ ./configure make make test sudo make install
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.
sudo aptitude install 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.
security = 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.
[jack] path = /home/jack public = yes writable = yes browsable = yes read only = no force user = jack force group = jack hosts allow = 127.0.0.1 192.168.2.5
At this point we have a working Ubuntu Ruby 1.9 development environment that we can access from Windows.blog comments powered by Disqus