Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing nokogiri 1.6.0 on mac (libxml2)

UPDATE: Fixed

I found the answer in another thread. The workaround I used is to tell Nokogiri to use the system libraries instead:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

====

Trying to install nokogiri 1.6.0 on a mac. With previous versions, I had no problems. But 1.6.0 refuses to install. This is the error:

    Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/i686-apple-darwin11/ports/libxml2/2.8.0... ERROR
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: Read 3 bytes from /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0/ports/archives/libxml2-2.8.0.tar.gz
tar: Error exit delayed from previous errors
*** 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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/josenriq/.rvm/rubies/ruby-1.9.3-head/bin/ruby
/Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:234:in `extract_file': Failed to complete extract task (RuntimeError)
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:34:in `block in extract'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:32:in `each'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:32:in `extract'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:98:in `cook'
    from extconf.rb:101:in `block in <main>'
    from extconf.rb:119:in `call'
    from extconf.rb:119:in `block in <main>'
    from extconf.rb:109:in `tap'
    from extconf.rb:109:in `<main>'


Gem files will remain installed in /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out

Seems like it has something to do with the libxml2 tar file not being able to extract.

Any ideas? I've done maybe 8 hours of research to no avail. Thanks!

like image 552
Jose Enrique Avatar asked Jul 25 '13 16:07

Jose Enrique


People also ask

Can t install Nokogiri?

Solution. Uninstall all versions of Nokogiri on your system, and then re-resolve your dependencies (using bundle or gem install ). This error can occur when a version of Nokogiri installed for a different version of Ruby is used by an unsupported version of Ruby.

Where is libxml2 located?

If you find any file or directory with the substring libxml2 in /usr/local/include or /usr/local/lib (such as /usr/local/lib/libxml2.so ) then it is already installed.

What is Ruby gem Nokogiri?

Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).


1 Answers

I found the answer in another thread. The workaround I used is to tell Nokogiri to use the system libraries instead:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install
like image 85
Jose Enrique Avatar answered Oct 21 '22 22:10

Jose Enrique