"uninitialized constant Nokogiri (NameError)"


#1

I’m trying a very simple Ruby program:

require ‘nokogiri’

doc = Nokogiri::XML(File.open(“Alla.xml”))

Whenever I run this I get “uninitialized constant Nokogiri
(NameError)”

Nokogiri is installed as far as I know, here’s my “gem list” output:

c:\dev>gem list

*** LOCAL GEMS ***

fxri (0.3.7, 0.3.6)
fxruby (1.6.19, 1.6.12)
hpricot (0.8.1, 0.6)
log4r (1.0.5)
nokogiri (1.2.3)
ptools (1.1.6)
rake (0.8.4, 0.7.3)
rubygems-update (1.3.2)
sources (0.0.1)
test-unit (2.0.2)
win32-api (1.4.0, 1.0.4)
win32-clipboard (0.4.4, 0.4.3)
win32-dir (0.3.3, 0.3.2)
win32-eventlog (0.5.0, 0.4.6)
win32-file (0.6.1, 0.5.4)
win32-file-stat (1.3.3, 1.2.7)
win32-process (0.6.0, 0.5.3)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.3.0, 0.2.0)
windows-pr (1.0.2, 0.7.2)

I would be very glad if anyone could help me find out why this doesn’t
work?

I’m a seasoned computer user but new to Ruby… so any pointers are
welcome. I’m using Ruby 1.8.6

c:\dev>ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

Cheers,
Joakim


#2

On Thu, Apr 23, 2009 at 2:55 PM, Yooakim removed_email_address@domain.invalid wrote:

I’m trying a very simple Ruby program:

require ‘nokogiri’

doc = Nokogiri::XML(File.open(“Alla.xml”))

try:

require “rubygems”
require “nokogiri”

#…

On Ruby 1.8.x, Rubygems needs to be explicitly enabled.

-greg


#3

On Apr 23, 2009, at 11:55, Yooakim wrote:

I’m trying a very simple Ruby program:

require ‘nokogiri’

doc = Nokogiri::XML(File.open(“Alla.xml”))

Whenever I run this I get “uninitialized constant Nokogiri
(NameError)”

Let me guess, you named your program ‘nokogiri.rb’, don’t do that.


#4

Yooakim wrote:

I’m trying a very simple Ruby program:

require ‘nokogiri’

Google would have instantly lead you to:

require 'rubygems'
require 'nokogiri'