11

Mac users, see: Mac user and getting WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3

I'm using linux (openSUSE 12.3) and running nokogiri -v shows:

WARNING: Nokogiri was built against LibXML version 2.8.0, but  dynamically loaded 2.9.0
# Nokogiri (1.6.0)
---
warnings:
- Nokogiri was built against LibXML version 2.8.0, but  dynamically loaded 2.9.0
nokogiri: 1.6.0
ruby:
  version: 2.0.0
  platform: x86_64-linux
  description: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
  engine: ruby
libxml:
  binding: extension
  source: packaged
  libxml2_path: /home/william/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/ports/x86_64-suse-linux/libxml2/2.8.0
  libxslt_path: /home/william/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/ports/x86_64-suse-linux/libxslt/1.1.26
  compiled: 2.8.0
  loaded: 2.9.0
Community
  • 1
  • 1
William Herry
  • 1,430
  • 14
  • 26

1 Answers1

23

The implicit question here seems to be "why am I getting this warning, and what can I do about it?"

You are getting the warning because Nokogiri was built (it is a largely native-extension gem, requiring compilation) against LibXML version 2.8.0, and your system has since upgraded LibXML to version 2.9.0.

This is a warning, not at error -- in many cases, Nokogiri will continue to work fine with a newer version of LibXML than it was built against.

If you run into problems or just want to be on the safe side, rebuilding Nokogiri will solve the issue -- it will be built against the version of LibXML currently installed.

Darshan Rivka Whittle
  • 32,989
  • 7
  • 91
  • 109
  • 1
    @dashan can you tell me how to rebuild Nokogiri with right libxml version? – William Herry Jul 01 '13 at 08:48
  • 1
    @WilliamHerry There are a lot of variations, but the most common is probably `gem install nokogiri`. However you installed Nokogiri in the fist place should just be repeated. It should automatically build against the "right" (current) version. – Darshan Rivka Whittle Jul 01 '13 at 08:52
  • 2
    I already gem uninstall nokogiri and gem install nokogiri for many times, not work, I don't know why. from output of nokogiri -v, it seems nokogiri build use libxml within .rvm, so, is there a way to make it build use libxml of my system version, or how to upgrade libxml version to 2.9 managed by rvm – William Herry Jul 01 '13 at 08:56
  • 13
    solved by `gem install nokogiri -- --with-xml2-include=/usr/include/libxml2/libxml --with-xml2-lib=/usr/lib64/ --with-sxlt-include=/usr/include/libxslt --with-xslt-lib=/usr/lib64/` – William Herry Jul 01 '13 at 12:18
  • 2
    I was tempted to mark this as a duplicate, because this question has been asked and answered half a dozen times, each with slightly different OS and version variants. But this answer is the only one that explains *why* it happens, and may help others figure out a solution (as it did the OP). Now I wish we could mark the others as duplicates or otherwise combine them. Anyway, +1 to you. – Mark Thomas Jul 01 '13 at 15:14
  • @WilliamHerry interestingly enough, the deprecation warning still gets displayed when doing `nokogiri -v` do you know what's going on here? – Steve Apr 04 '14 at 01:01
  • If reinstalling the gem does not help you might also have to re-link the lib: ``brew link libxml2 -f`` – chrpes Jun 24 '16 at 13:10