Nokogiri is an XML parsing library, and is effectively a clever wrapper around LibXML, which is a library for parsing XML which is written in C. Nokogiri includes C extensions to interface its Ruby code to LibXML. When you install the gem, it'll compile against the libxml headers available on the system, but at runtime it'll dynamically link against the libxml shared object available on the system. You get this warning when those versions don't match - for example, if you upgrade libxml2 on your system after you install Nokogiri.
The way you fix this is to specify which version of LibXML Nokogiri should build against. You can set this up in ~/.bundle/config
, like:
---
BUNDLE_BUILD__NOKOGIRI: --with-xml2-lib=/opt/libxml/lib--with-xml2-include=/opt/libxml/include/libxml2 --with-xslt-lib=/opt/libxml/lib --with-xslt-include=/opt/libxml/include
This basically just sets compile flags to be passed when building Nokogiri's extensions, which lets you specify the location of the LibXML installation to use. Uninstall Nokogiri and let Bundler reinstall it after putting that config (and the right libxml2 version) in place, and all will work as expected.