开发者

require nokogiri: Load Error

开发者 https://www.devze.com 2023-04-12 10:46 出处:网络
I\'m new to Ruby and I was looking around for libraries to parse html and found Nokogiri. The problem I\'m having is if I fire up IRB and type require \'nokogiri\', it works fine and prints out true.

I'm new to Ruby and I was looking around for libraries to parse html and found Nokogiri. The problem I'm having is if I fire up IRB and type require 'nokogiri', it works fine and prints out true. But if I include that as a part of my .rb file and execute it with ruby <scriptname>, it gives me a LoadError: no such开发者_JAVA技巧 file to load message.

My Ruby version is 1.8.7 if I type ruby --version in the terminal.


Try adding

require 'rubygems'

to the .rb file.

In Ruby 1.9+ rubygem is loaded automatically and not needed. Although there is debate whether that line is required pre 1.9.

Nevertheless, give it a shot.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号