How to load the correct version of dynamic libraries and precious stones (libxml, Nokogiri) into your own native Rails engine?

I am creating a rail engine that uses the Nokogiri gem, and I'm having trouble setting up development on MacOS 10.7 and 10.8:

In order for Nokogiri to work correctly in my installation, I updated the libxml and libxslt libraries with

brew update brew install libxslt brew upgrade libxml2 gem uninstall nokogiri gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 

And Nokogiri works correctly if I use it in a "regular" rails application (include it in the Gemfile, run the package installation).

The problem occurs when I try to use Nokogiri from the Rails Engine, which I create and use from my application as a gem.

In gemspec:

 s.add_dependency 'nokogiri' # XML parsing 

I also tried the following at the top of the Gem Gemfile:

 gem 'nokogiri' 

When I launch an application using the Rails Engine modem, I get the following warning:

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

How to configure gem and / or bundler and / or Rails to use the correct version of Nokogiri and libxml and libxslt?

Also here is the output of nokogiri -v

 # Nokogiri (1.5.9) --- warnings: [] nokogiri: 1.5.9 ruby: version: 1.9.3 platform: x86_64-darwin12.3.0 description: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0] engine: ruby libxml: binding: extension compiled: 2.9.0 loaded: 2.9.0 
+2
ruby ruby-on-rails libxml2 nokogiri rails-engines
Jun 04 '13 at 15:26
source share
1 answer

Install the Rails Engine application on the Gemfile system Then, in the gemspec and Gemfile from the Rails Engine, make sure you have nokogori in front of other gems that use libxml (like pg).

+8
Jun 05 '13 at 14:50
source share



All Articles