user2002730
user2002730

Reputation: 203

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'

Upvotes: 20

Views: 27874

Answers (9)

Asmita
Asmita

Reputation: 183

Nokogiri generally uses system libraries. So, your ruby has it installed already just make sure that you've run below command before start bundle install.

rvm use ruby-2.2.4 (your current ruby-version)

Sometimes, you also need to run first

  1. /bin/bash --login
  2. rvm use ruby-2.2.4

Note: Only if you're using rvm

Upvotes: 0

Fernando Osorto
Fernando Osorto

Reputation: 73

Try the following inside your project directory.

gem uninstall nokogiri

If there are more than one versions installed, a prompt will appear asking which version to remove. use the last option that reads "All versions".

Next, run bundle install inside your project directory. once it finishes installing the needed gems you should be good to go.

In my case, I hit the last option "All versions" as it doesn't hurt my project but it is possible that you might need the other versions based on different projects.

Upvotes: 1

F&#225;bio BC Souza
F&#225;bio BC Souza

Reputation: 1220

First gem uninstall nokogiri Second install nokogiri third restart terminal

be happy

Upvotes: 1

sirko
sirko

Reputation: 143

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

gem install nokogiri -- --use-system-libraries

Upvotes: 7

Shepmaster
Shepmaster

Reputation: 431579

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.

Upvotes: 3

vaughanos
vaughanos

Reputation: 521

Reinstalling the gem didn't work for me, nor did pulling the particular branch.

It's not ideal, but I found that rolling back to 1.5.9 solved the issue.

Upvotes: 0

neuromantix
neuromantix

Reputation: 41

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 

Upvotes: 4

Paulo Cheque
Paulo Cheque

Reputation: 2836

First, check your version of libxml:

otool -L /usr/lib/libxml2.2.dylib

It can return

/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 11.0.0, current version 11.0.0)

or

/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)

Then you can try reinstalling libxml to upgrade it:

brew uninstall libxml2 libxslt
brew install libxml2 libxslt

After that, try to recompile your package:

make clean
./configure
make
sudo make install

Upvotes: 0

Ryan Linton
Ryan Linton

Reputation: 1285

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.

Upvotes: 43

Related Questions