Forum: Ruby "uninitialized constant Nokogiri (NameError)"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D45f57d04f265308404ebbfeee39daf2?d=identicon&s=25 Yooakim (Guest)
on 2009-04-23 20:56
(Received via mailing list)
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
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2009-04-23 21:02
(Received via mailing list)
On Thu, Apr 23, 2009 at 2:55 PM, Yooakim <yooakim@gmail.com> 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
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-23 21:10
(Received via mailing list)
Yooakim wrote:

> I'm trying a very simple Ruby program:
>
>   require 'nokogiri'

Google would have instantly lead you to:

    require 'rubygems'
    require 'nokogiri'
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2009-04-23 22:30
(Received via mailing list)
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.
This topic is locked and can not be replied to.