Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib

I'm getting this error when trying to run rspec in Hartl's tutorial. I googled the error, but it's never for the specific version and the fixes don't actually fix my problem.

/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-           1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded:    /Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple-   darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-  1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
like image 362
user2002730 Avatar asked Sep 16 '13 00:09

user2002730


4 Answers

I suggest you first uninstall Nokogiri using:

sudo gem uninstall nokogiri

Then install Nokogiri using rubygems:

gem install nokogiri

If that doesn't work, there's an open issue on Nokogiri to support libxml 2.9.0 and later. There's a libxml2-2.9.1 branch that was started in preparation for the next release of libxml2.

Then try pulling from that branch in your Gemfile like this:

gem "nokogiri", github: "sparklemotion/nokogiri", branch: "libxml2-2.9.1"

or install an older version of libxml2.

If that still doesn't work you may also want to try the suggestions here: What to do if libxml2 is being a jerk.

like image 148
Ryan Linton Avatar answered Nov 09 '22 09:11

Ryan Linton


Not sure if it helps anyone, but I could just get nokogiri installed by using system libs

gem install nokogiri -- --use-system-libraries
like image 23
schmierkov Avatar answered Nov 09 '22 11:11

schmierkov


If you have Homebrew installed, try this. It solves the issue with the "Parsing documentation for nokogiri-1.6.1" hang. This worked for me.

gem uninstall nokogiri libxml-ruby

It'll ask you a series of questions based on how much of it you want to uninstall, answer "yes" or "[y]" to all.

brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link --force libxml2
brew install libxslt 
brew link --force libxslt 

gem install nokogiri --no-rdoc --no-ri 

Then, in your project file:

bundle install 
like image 4
neuromantix Avatar answered Nov 09 '22 10:11

neuromantix


Your error message says:

nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0

This makes me think that your gem actually requires a version of libxml that is newer than your system version. How have you installed libxml2? If you have homebrew installed, you might want to try upgrading it with

brew update
brew upgrade

I was able to install Nokogiri 1.6.0 with Ruby 2.0.0p247 on OS X 10.9, and then require it in IRb. I double checked with Homebrew, and it is actually keg-only. However, Nokogiri seems to install its own version into gems/nokogiri-1.6.0/ports. On my machine, it is under x86_64-apple-darwin13.0.0.

like image 3
Shepmaster Avatar answered Nov 09 '22 11:11

Shepmaster