Question

I've just updated to OS X Mountain Lion and I'm getting the following when working with rails and terminal.

WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8

I've had a look at other answers to a similar question, but they doesn't seem to stop the warning message from appearing.

Was it helpful?

Solution

Putting gem 'nokogiri' above gem 'pg' in my Gemfile fixed this for me.

My Gemfile didn't have nokogiri in it, but it was a dependency that was in Gemfile.lock, so I put it in my Gemfile explicitly.

OTHER TIPS

I was having similar issues installing nokogiri gem on ruby 1.9.2 Apparently Apple upgraded gcc... I fixed this with a symlink and then the gem installed just fine:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

Passing flags to install gems is generally a bad idea if you've got a Gemfile and are using bundler. Even if you're not, you'll be on a custom-compiled libxml and you probably won't remember...! I started by hacking around trying to get this to work and even brew installing libxml2.

Turns out, if you reinstall (and therefore recompile) the ruby version you're working with (hopefully with rvm), it'll work.

So, for RVM users:

    rvm list (gets your rubies - choose the one being used)
    rvm uninstall RUBY_VERSION
    rvm install SAME_RUBY_VERSION
    bundle (or gem install nokogiri)

It did the trick for me.

Using Ruby 1.9.3-p194 and Rails 3.2.11 on OS X 10.8.2 (Mountain Lion), starting rails c gave the warning:

WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8

The uninstall/install nokogiri trick didn't work for me. The solution was much simpler... The warning was avoided completely by editing the Gemifile to place 'nokogiri' above 'pg'.

References:

all the solution listed so far in here didn't work for me.

So, I did a brew uninstall libxml2 it was the version libxml2 2.8.0 and i guess my os x has libxml2 version 2.7.8 pre-installed

then i did gem uninstall nokogiri and then gem install nokogiri

Warning is gone now. But it's libxml2 version 2.7.8 and not the latest. So, I appreciate, if you suggest some solution that work with latest version of libxml2.

I just had this problem.

My problem was solved surprisingly easily.

gem uninstall nokogiri

Selected all versions

Then gem install nokogiri and it went away.

if you are using home-brew, you can brew update and brew doctor. Upgrading to mountain lion even removed my git and stuff. I installed it back by installing cc tools in Xcode and using brew doctor to make sure it's raring to go before the above.

So I ended up using the following command:

bundle config build.nokogiri --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26/

And then doing:

gem uninstall nokogiri
gem install nokogiri

And then ran

bundle install

Nothing seemed to work for me to fix this one.

Then I went into xcode and installed the updated command line tools, then gem uninstall nokogiri and gem install nokogiri and it worked!

After upgrading ruby-build

brew update
brew upgrade ruby-build

I just reinstalled ruby (last version)

rbenv install 1.9.3-p194

and then I installed all the gems related to my project including nokogiri without having further problems.

gem install bundler
bundle
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top