Tuesday, May 22, 2007

Ruby: Gems not working

Before I dive into the dreaded Assembly Dissasembler project tonight, I thought I'd pre-reward myself with a little Ruby fun. Mike Clark has an interesting post about using tests to teach yourself Ruby. Wanting to use that as a springboard, I tried to play with some gems, and immediately got stuck. Whatever module I tried to include a module from a gem, Ruby came back with:

001.rb:2:in `require': no such file to load -- mp3info (LoadError)
from 001.rb:2
This stumped me as the gem said it had installed succesfully.

I'm running on my beloved new Ubuntu system and this is the first big problem I've had. After about an hour of googling and trying random hunches, I discovered that for some reason, the standard install of ruby gems (from the ubuntu repos, not from source) apparently doesn't set the RUBYOPT variable to ruby gems, so you must either set it yourself by including export RUBYOPT=rubygems in your .bashrc file (assuming you're running the bash shell), or by explicitly including require 'rubygems' at the beginning of each script. I puzzled this out from a post on onrails.org. First big Ruby stumbling block solved.

0 snarky replies: