Q:

nokogiri: relocation error in production environment

We have a build pipeline in the Rails project: we bundle and test application in the test server and then we copy it (code with gems in vendor/) to the staging server and deploy it to a passenger server.
It used to work, but now I get following error in the apache.error.log:  
WARNING: Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
/usr/local/rvm/rubies/ruby-1.9.2-p318/bin/ruby: 
  relocation error: /home/project/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/lib/nokogiri/nokogiri.so: 
  symbol xmlNextElementSibling, version LIBXML2_2.7.3 not defined in file libxml2.so.2 with link time reference

and error 500 in the browser.
When I run webbrick on the staging server U get similar errors on first request. How could I solve it?
EDIT:
Stange thing with nokogiri version. The same binary loads different libxml version depending if I call it standalone or with bundle exec:
vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri  -v
# Nokogiri (1.5.2)
---
warnings: []
nokogiri: 1.5.2
ruby:
  version: 1.9.2
  platform: x86_64-linux
  description: ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]
  engine: ruby
libxml:
  binding: extension
  compiled: 2.6.26
  loaded: 2.6.26

$ bundle exec vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.2/bin/nokogiri  -v
WARNING: Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
# Nokogiri (1.5.2)
---
warnings:
- Nokogiri was built against LibXML version 2.7.6, but has dynamically loaded 2.6.26
nokogiri: 1.5.2
ruby:
  version: 1.9.2
  platform: x86_64-linux
  description: ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]
  engine: ruby
libxml:
  binding: extension
  compiled: 2.7.6
  loaded: 2.6.26

A:

I resolved the problem. I built libxml2 from source and then I configured bundler to use this new version:
bundle config build.nokogiri --with-xml2-dir=/usr --with-xslt-dir=/usr/local

(Now it I have a warning, because the version that is loaded is newer that the one that was used to built Nokogiri, but it's not a problem). 

