I got a call today from someone who had upgraded their desktop from Ubuntu 8 to Ubuntu 12 and was having trouble getting Ruby reinstalled. She had previously installed Ruby from source (as apparently everyone needs to do in the Debian/Ubuntu world) without any problem - but not this time. I do a reasonable amount of Ruby and system administration but I work in a RedHat shop so don’t know a ton about Debian-derived distros. But I thought I would try to see what I could do to help.
Installing Ubuntu 12.04
First thing I need is an Ubuntu box to practice on. I had VirtualBox installed and have used Vagrant to manage some boxes. However, since Vagrant is written in Ruby and usually does its configuration of the box with Chef or Puppet, I think the premade vagrant images will already have Ruby installed. - making it difficult to figure out the correct steps for installing Ruby from source. So I think I should install Ubuntu without my favorite virtualization tool.
First, I upgraded my VirtualBox software to 4.2.4. (My older boxes appear to still run but they appear to have lost their Guest Additions; I’ll have to go back and sort that out).
Ubuntu is pretty common so I searched for a prebuilt (hopefully minimal) VirtualBox image and found a promising looking one at http://virtualboxes.org/images/ubuntu/. I downloaded this one:
First issue: that is compressed with 7zip so I’ll need p7zip to uncompress it. Fortunately I have Homebrew installed so I just did:
This installed a formula it said was p7zip from https://github.com/mxcl/homebrew/commits/master/Library/Formula/p7zip.rb and brew list p7zip shows:
After a little fishing around I think the uncompress command is ‘7z x
This produces a folder named ubuntu_12.04 containing a small .vbox file and 3.5 GB .vdi file. The later is the ‘virtual disk image’ file that we will want to use to create our new VM. I followed [these instructions] (http://www.thelinuxdaily.com/2010/02/how-to-setup-a-pre-built-virtualbox-guest-image-tutorialguide/) and created a new VM with 512 MB RAM and using the pre-existing .vdi file. Then I just start the newly created VM from the menu.
There are a couple of peculiarities - the main one is that the requested keyboard is Italian. I found the keyboard settings and chose an English keyboard layout instead. Then I changed the update server to the server for the US and upgraded packages. The GUI says it wants to do 489 updates!
VirtualBox Guest Additions
Oh, and I don’t need the Guest Additions for preventing the VirtualBox from capturing my mouse but I do need them so I can cut and paste between the host and guest OSs. Under the VirtualBox Devices menu there is an item for Install Guest Additions. Clicked that to get them installed. However even though I rebooted the virtual machine, I still can’t copy and paste between the VM to my Mac.
OK now for installing Ruby. The person I am helping was installing Ruby globally from source but I wanted to see if RVM could install Ruby 1.8.7 for me. First I installed rvm:
That added a .bash_profile to my home directory. That didn’t play well with my shell in emacs so I moved that line to my .bashrc file. Then I installed ruby and made it my default ruby:
That worked just fine - but I can’t install any gems.
Sounds like I am missing some dependencies. Fortunately RVM will tell me what it needs - and in Ubuntu syntax:
However, once I installed those, I still wasn’t able to install any gems. Apparently I should have installed the prerequisites BEFORE I installed the ruby. Once I got the order correct, installing ruby 1.8.7 via RVM also installed 4 gems: