4

I recently did a clean install of Mountain Lion, and after installing Nokogiri - got an error when starting up the Rails console: WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8

So I looked at other questions here on SO, and uninstalled everything and tried again, but I noticed the install instructions are out of date on the Nokogiri website: http://nokogiri.org/tutorials/installing_nokogiri.html

Because 'brew install libxml2 libxslt', actually installs libxml2 2.8.0, and reading further down the instructions it refers to 2.7.8:

gem install 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 
                    --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include 
                    --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

(notice libxml2/2.7.8)

So I uninstall again, and reinstall with: (libxml2/2.8.0)

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib

And while it seems to work fine in IRB, it doesn't in Rails C - it still says:

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

I've tried running bundle update, but it's still the same.

Any ideas how I can fix this please?

A4J
  • 879
  • 10
  • 24
  • I'm having the same issue. The output of `nokogiri -v` says: `compiled: 2.8.0, loaded: 2.8.0`. Seems to be a weird issue only with Rails. – Chris Lloyd Aug 16 '12 at 00:07
  • 2
    Try brew uninstall libxml2 and try again (if that doesn't work uninstall nokogiri and reinstall it). Also, add the PG gem near the top of your gemfile. – A4J Aug 18 '12 at 23:10

3 Answers3

2

so you first ran gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib ... and it still said "Nokogiri was built against LibXML version 2.8.0"? that looks almost as if it didn't pay attention to the switches.

anyway, the problem is exactly as stated by your computer: the libxml*.so it uses at runtime is the old version. try man ldconfig, look in the standard dirs for the old libxml library. it might be enough to put the new one next to it and point the symlink at it.

disclaimer: i'm not an osxer, buyer beware.

just somebody
  • 18,602
  • 6
  • 51
  • 60
  • 1
    Hi, I'm not sure about the original error now as I didn't take a note of it (the versions might have been flipped?). I tried your suggestion of 'man ldconfig', but it says 'No manual entry for ldconfig'. Can you think of anything else I can try? Thanks! – A4J Aug 03 '12 at 17:21
  • you can try posting the actual error message. also, this wasn't so hard to find: http://stackoverflow.com/questions/1451047/ldconfig-for-mac-os-x – just somebody Aug 10 '12 at 21:35
1

Unless you have a pressing need to use a newer version of libxml2, the standard version distributed with OS X Mountain Lion will do just fine. I have used

brew uninstall libxml2
brew uninstall libxslt

gem uninstall nokogiri
gem install nokogiri

to good effect. The re-installation of Ruby 1.9.3 recommended here was not necessary. Of course, libxslt needs to be uninstalled only if you had installed it previously (as I had).

If you do uninstall one of the libraries, you might wish to check via

brew missing

whether you have accidentally removed a dependency.

Community
  • 1
  • 1
C.Sage
  • 71
  • 2
0

Check your gemfile and make sure nokogiri is implicitly defined -- don't rely an implied inclusion to give you the correct version of the nokogiri gem.

Then uninstall libxml2 and libxslt if you have them installed via brew, uninstall nokogiri via gem, and reinstall it via bundler install.

IAmNaN
  • 10,305
  • 3
  • 53
  • 51