0

Rails Cast No 190を聞いた後、座って試してみました

だから私はnokogiriをインストールしました

gem install nokogiri

私のWindows 7 Ultimateラップトップで。私はRuby1.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 

タイトルの形で結果を取得しようとしましたが、次のエラーが発生しています!!

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たが、それでもエラーを取り除くことができません。

それを修正するのを手伝ってください!!

ありがとう

ゴータム

4

2 に答える 2

0

これは、Ruby 1.9.1の既知の問題のようです。問題を絞り込むために、Ruby 1.8.7 でもう一度試してください。

于 2010-05-26T16:45:25.413 に答える
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再インストールを試みてください。

于 2010-05-26T15:26:48.300 に答える