views:

116

answers:

3

After listening to Rails Cast No 190 I sat down to try it

So I installed nokogiri with

gem install nokogiri

on my Windows 7 Ultimate laptop. I use Ruby 1.9

and this is the way i Installed Nokogiri

C:\Ruby>gem install nokogiri
Successfully installed nokogiri-1.4.2-x86-mingw32
1 gem installed
Installing ri documentation for nokogiri-1.4.2-x86-mingw32...
Updating class cache with 1221 classes...
Installing RDoc documentation for nokogiri-1.4.2-x86-mingw32...

Now for the following code hello.rb

require 'rubygems'  
require 'nokogiri'  
require 'open-uri'  

url = "http://timesofindia.indiatimes.com/rssfeeds/-2128838597.cms"  
doc = Nokogiri::HTML(open(url))  
puts doc.at_css("title").text 

I tried to get a result in the form of Title but I am getting the following error!!

C:\Ruby>ruby hello.rb
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogir
i.rb:1:in `require': 127: The specified procedure could not be found.   - Init_n
okogiri (LoadError)
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/1.9/nok
ogiri.so
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri/nokogiri.rb:1:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `<top (required)>'
        from hello.rb:2:in `require'
        from hello.rb:2:in `<main>'

I have tried to uninstall and reinstall with gem uninstall nokogiri but still i cant get rid of the error.

Please help me to fix it!!

Thanks

Gautam

A: 

When you installed Nokogiri did you get the following question, and what option did you choose?

 C:\Documents and Settings\Username>gem install nokogiri
 Bulk updating Gem source index for: http://gems.rubyforge.org
 Select which gem to install for your platform (i386-mswin32)
  1. nokogiri 1.0.6 (ruby)
  2. nokogiri 1.0.6 (x86-mswin32-60)
  3. nokogiri 1.0.5 (x86-mswin32-60)
  4. nokogiri 1.0.5 (ruby)
  5. Skip this gem
  6. Cancel installation
 >

You should have chosen the x86-mswin32-60 version. It looks like you have a non-windows version installed.

If you chose one of the ruby options then try gem uninstall nokogiri and then install again

Steve Weet
A: 

I uninstalled as you said

C:\Ruby>gem uninstall nokogiri
Remove executables:
        nokogiri

in addition to the gem? [Yn]  y
Removing nokogiri
Successfully uninstalled nokogiri-1.4.2-x86-mingw32

Now I installed nokogiri with gem install nokogiri

C:\Ruby>gem install nokogiri
Successfully installed nokogiri-1.4.2-x86-mingw32
1 gem installed
Installing ri documentation for nokogiri-1.4.2-x86-mingw32...
Updating class cache with 1221 classes...
Installing RDoc documentation for nokogiri-1.4.2-x86-mingw32...

Now for the following program hello.rb

require 'rubygems'  
require 'nokogiri'  
require 'open-uri'  

url = "http://timesofindia.indiatimes.com/rssfeeds/-2128838597.cms"  
doc = Nokogiri::HTML(open(url))  
puts doc.at_css("title").text 

I am getting the following error again!!

C:\Ruby>ruby hello.rb
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/nokogir
i.rb:1:in `require': 127: The specified procedure could not be found.   - Init_n
okogiri (LoadError)
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nokogiri/1.9/nok
ogiri.so
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri/nokogiri.rb:1:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.2-x86-mingw32/lib/nok
ogiri.rb:13:in `<top (required)>'
        from hello.rb:2:in `require'
        from hello.rb:2:in `<main>'

Please help me solve this problem. I use Windows 7 Ultimate version. Ruby 1.9

reko
A: 

This appears to be a known issue with Ruby 1.9.1. Try it again with Ruby 1.8.7 to narrow down your problem.

jdl