Search code examples
ruby-on-railsrubyruby-on-rails-3rubygemslibxml2

Gem install ignore flags for nokogiri


I'm trying to install nokogiri version 1.6.0 and have some issues with it.

$ gem install nokogiri -v '1.6.0' -- --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
Building native extensions with: '--with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28'
This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/shamatov/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
Extracting libxml2-2.8.0.tar.gz into tmp/i686-apple-darwin11/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/shamatov/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/i686-apple-darwin11/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Users/shamatov/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxslt/1.1.26)...
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

As you can see, I use: --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 but extconf.rb uses libxml2-2.8.0.tar.gz Same to xslt it uses libxslt-1.1.26.tar.gz

How to fix this issue, cause changing version is not an option actually? thanks


Solution

  • Try to:

    $ gem uninstall nokogiri # JIC
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri \
        -- --use-system-libraries \
           --with-iconv-dir="$(brew --prefix libiconv)" \
           --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" \
           --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
    

    Hope it helps.