Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nokogiri failing to upgrade

Tags:

ruby

gem

nokogiri

Anyone seen this?

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

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150524-28193-cqkmxr.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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
        --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
like image 224
smcracraft Avatar asked May 24 '15 15:05

smcracraft


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.

How do I install a specific version of a gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

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).

What does Nokogiri do?

Nokogiri (htpp://nokogiri.org/) is the most popular open source Ruby gem for HTML and XML parsing. It parses HTML and XML documents into node sets and allows for searching with CSS3 and XPath selectors. It may also be used to construct new HTML and XML objects.


2 Answers

I've just had this same problem on a fresh Ubuntu 14.04 box and it turns out there is a dependency for the zlib source (i.e. zlib.h) so you need to:

On Ubuntu or Debian:

sudo apt-get install zlib1g-dev 

On Fedora, CentOS or RHEL:

sudo yum install zlib-devel 

Or find the equivalent package for your operating system.

like image 183
Michael M Avatar answered Oct 01 '22 14:10

Michael M


You need to install the missing dependencies, e.g.:

sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev

Then try again:

gem install nokogiri
like image 22
Edson Villar Avatar answered Oct 01 '22 14:10

Edson Villar