A collection of computer systems and programming tips that you may find useful.
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Wednesday, January 7, 2009

Ruby and the RubyInline gem

I wanted to transfer a Ruby app that used the Inline gem to a Linux machine and had trouble getting it to work. Here are the steps needed to make it work.

The ruby code uses the Inline gem which allows you to write inline C code in your application for better performance. The code itself includes this line:
require "inline"

In transferring it to a new machine (linux in this case - Fedora and Ubuntu machines in fact) I would get the error "undefined method 'inline'".

I figured this meant I did not have the 'inline' gem so I ran 'sudo gem install inline'. But after that I still got the same error... WRONG GEM! I finally figured out that I want to install RubyInline not inline... plus you also need the hoe gem
$ sudo gem install RubyInline
$ sudo gem install hoe

Tried running the app and this time I got:
ERROR: Can't find header dir for ruby, Exiting...

This tells me that I need a development version of Ruby with all the header files. A regular ruby install does not give you this.

On Mac OS X you need to install the Xcode developer tools.
On Ubuntu you need to do this:
$ sudo apt-get install ruby-dev
On Fedora you would do:
$ sudo yum install ruby-devel

Try it once more and it should work!


Mina Naguib said...

You can avoid the confusion by having your code explicitly say "I need the RubyInline gem" like so:

>> gem "RubyInline"
>> require "inline"

brinkka said...

I recently came across your blog and have been reading along. I think I will leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
By : http://www.factspenisenlargement.com

Archive of Tips