I have installed nokogiri on my system running OSX 10.8.3, Ruby 2.0.0p0, Rails 3.2.13. When trying to run a simple test script beginning with
require 'rubygems'
require 'nokogiri'
require 'open-uri'
I get the error:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- nokogiri (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/jerome/Documents/MyFiles/Developer/testruby.rb:2
Does nokogiri currently support Ruby 2.0 on OSX?
edit: This issue arose while building from Sublime Text 2. Script works fine on irb.
Nokogiri is supported.
In the initial question, I had been building from Sublime Text 2. This produced the error, whereas doing so on irb worked fine.
The solution from http://rubenlaguna.com/wp/2012/12/07/sublime-text-2-rvm-rspec-take-2/ worked for me. This changed the default path Sublime was finding Ruby in.
Solution:
Update ~/Library/Application\\ Support/Sublime\\ Text\\ 2/Packages/Ruby/Ruby.sublime-build to
{
"env":{
"PATH":"${HOME}/.rvm/bin:${PATH}"
},
"cmd": ["rvm-auto-ruby", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
Also, I apologize for my mistake of not initially posting that I was getting the error from Sublime Text 2.
The path shown in your error output indicates you're using the system-default version of Ruby (1.8.7), since it is referencing /System/Library/Frameworks/Ruby.framework/Versions/1.8
. You likely need to ensure you're using the correct ruby
binary for 2.0.
If you installed via RVM, you can run something like rvm use 2.0.0
, or use a .ruby-version
or .rvmrc
file in your source project. Or else simply invoke the 2.0.0 ruby
binary directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.