I decided to follow Chad’s advice and take Rubinius for a spin. Everything worked great until I tried running some of my more complicated scripts, each of which experienced failures on a ‘require’ statement.
After narrowing down which require statements were working and which were not, I realized I had two classes of failures: (1) my own modules that I had placed in the require path, and (2) gems. Built-in modules (like optparse) were OK. Sure enough, the command:
rbx -e 'puts $:'
revealed that the require path for rubinius is completely separate from that of MRI (Matz’s Reference Implementation). So, I copied my modules into the
/usr/local/lib/ruby/site_ruby/rubinius directory, but that didn’t help. I also had to
rbx -c each of them, to produce the corresponding .rbc file. UPDATE 2010-11-18: This was probably a red herring, caused by something else I fixed later (maybe the missing gems). See comment thread below.
That fixed my modules, but gems still wouldn’t load. The require for ‘rubygems’ itself was OK, however. So I figured there must be something different about installing gems for Rubinius. After a bit of googling, I found a comment posted by someone named “?”, who said in part:
In case you haven’t tried Rubinius yet, let me save you a bit of googling and tell you that to install gems you just write: “rbx gem install …”
Bingo. I proceeded to
rbx gem install each of the gems that I use. But when I attempted sqlite3, I got:
ERROR: Error installing sqlite3: sqlite3 requires Ruby version >= 1.9.1. shell returned 1
Tartar sauce! Rubinius isn’t available for 1.9 yet, though they say it’s “coming soon”. Yeah, that’s what she said, too. I guess I’ll have to just keep plugging along with MRI for now. The one script for which I really hoped to get a performance boost from Rubinius is my spam filter, isspam, but I don’t feel like rewriting its database interface.
UPDATE 2010-11-18: Evan Phoenix provided the solution in the comments below: I was using the wrong gem! Should have been sqlite3-ruby instead of sqlite3 (odd that both exist). Thanks again, Evan!