Thursday, March 30, 2006

Ruby LoadError, Quick fix

Ruby library load error, takes long time for a newbie but simple hack could get you up and running with your thing.
I just installed RubyFul_Soup[ Ruby port of the hit Python HTML/XML parser Beautiful Soup.] and wanted get started with RadRails , so when I write this line on top

require 'RubyFulSoup' as per the example given I get following error

LoadError: No such file to load -- rubyfulsoup

The thing is when you install any gem using "gem install" , it installs gem under /usr/lib/ruby/gems/1.8/gems , so somehow ruby does not really get where to pick up gems from , best thing to do a quick sanity check regarding your setup , and you can do that by "irb" (Interactive Ruby Shell), just type
bash> irb
irb(main):002:0> require 'RubyFulSoup'
LoadError: No such file to load -- RubyFulSoup
from (irb):2:in `require'
from (irb):2

basically gem installed is "rubyful_soup' and its under /usr/lib/ruby/gems/1.8/gems
and Ruby looks for files under /usr/lib/ruby/1.8/ , So all I did is copied rubyful_soup.rb file from /usr/lib/ruby/gems/1.8/gems to /usr/lib/ruby/1.8/ and also copy htmltools gem files to /usr/lib/ruby/1.8/, then run

irb(main):001:0> require 'rubyful_soup'
=> true

This is a quick fix till I figure out the real solution for this


5 comments:

Anonymous said...

Instead of copying files around, try this:

require 'rubygems'
require 'rubyful_soup'

Worked for me. :)

Rajesh Shetty said...

Will try that one, Thanks Kelly

Anonymous said...

requiring "rubygems" didn't work for me.

Anonymous said...

Super color scheme, I like it! Good job. Go on.
»

Anonymous said...

I say briefly: Best! Useful information. Good job guys.
»