铁路铸造中的问题第190集

时间:2010-05-26 16:30:19

标签: ruby-on-rails ruby rubygems nokogiri railscasts

听完Rails Cast No 190后,我坐下来试试

所以我用

安装了nokogiri
gem install nokogiri

在我的Windows 7 Ultimate笔记本电脑上。我使用Ruby 1.9

这就是我安装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...

现在提供以下代码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 

我试图以Title的形式获得结果,但是我收到以下错误!!

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>'

我尝试使用gem uninstall nokogiri卸载并重新安装,但我仍然无法摆脱错误。

请帮我修理!!

由于

高塔姆

2 个答案:

答案 0 :(得分:0)

当您安装Nokogiri时,您会得到以下问题,您选择了哪个选项?

 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
 >

您应该选择x86-mswin32-60版本。看起来您安装了非Windows版本。

如果您选择其中一个ruby选项,请尝试gem uninstall nokogiri,然后重新安装

答案 1 :(得分:0)

这似乎是带有Ruby 1.9.1的known issue。使用Ruby 1.8.7再次尝试来缩小您的问题范围。