From: Ross Bamford Date: 2006-03-24T02:35:41+09:00 Subject: Re: Problem seeing classes in rubygem On Fri, 2006-03-24 at 01:51 +0900, Wes Gamble wrote: > I have installed the gem correctly (it shows up when I do gem -list) and > my require_gem statement succeeds. > > However, when I go to instantiate one of the classes defined in this > gem, the call fails with: > > unitialized constant: BeautifulSoup > > on line 4 of my test case below. > > Here is my test case: > > require 'rubygems' > require_gem 'rubyful_soup', '>= 1.0.4' > > parser = BeautifulSoup.new(%{"kajsdlfkjads"}) require_gem does (by default) actually require anything inside the gem - it's just used to tell Gems about version constraints you want to have. You'll still have to require 'rubyful_soup' to actually load it. note 1: In normal use, Gems patches require to automatically load gems as needed, so you could have just had "require 'rubyful_soup'" and the latest installed version would be installed. If you really do need that version constraint, however, I think you have to keep the require_gem. note 2: Gems does support an 'autorequire' attribute in a gem's spec that allows it to automatically require a given file when the Gem itself is required, but this is deprecated and rubyful soup doesn't appear to use it. -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk