Failed to set Nokogiri stone

I am working on a rails application that allows you to embed images in every account you use. I use paperclip and amazon web services:

gem 'paperclip' gem 'aws-sdk' 

When I start the installation of the package, I get this message:

extconf failed, exit code 1

 Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling. 

When I try to run gem install nokogiri, I get this message:

extconf failed, exit code 1

 Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out 

My OS is Mac OS X 10.9.4 Mavericks. What's going on here? How can I get nokogiri to install and behave correctly?

Full stack trace :

 Building native extensions with: '--use-system-libraries' This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /usr/local/rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb --use-system-libraries checking if the C compiler accepts ... yes checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... yes Building nokogiri using system libraries. libxml2 version 2.6.21 or later is required! *** 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=/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby --help --clean --use-system-libraries --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --with-xml2-dir --without-xml2-dir --with-xml2-include --without-xml2-include=${xml2-dir}/include --with-xml2-lib --without-xml2-lib=${xml2-dir}/lib --with-libxml-2.0-config --without-libxml-2.0-config --with-pkg-config --without-pkg-config --with-xslt-dir --without-xslt-dir --with-xslt-include --without-xslt-include=${xslt-dir}/include --with-xslt-lib --without-xslt-lib=${xslt-dir}/lib --with-libxslt-config --without-libxslt-config --with-exslt-dir --without-exslt-dir --with-exslt-include --without-exslt-include=${exslt-dir}/include --with-exslt-lib --without-exslt-lib=${exslt-dir}/lib --with-libexslt-config --without-libexslt-config extconf failed, exit code 1 Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out 
+12
ruby ruby-on-rails rvm paperclip nokogiri
Dec 16 '14 at 2:18
source share
11 answers

It works like a charm!

 gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 

stack overflow

+28
Dec 16 '14 at 2:38
source share

Have you tried gem install nokogiri -v 1.6.5 -- --use-system-libraries ? Most nokogiri errors are related to libxml2, libxslt or libiconv config.

Nokogiri docs should give you more instructions. If the solution does not work, you can send a full stack trace so that others can help.

+7
Dec 16 '14 at 2:26
source share

after upgrading to Rails 4.2.4 (which includes Nokogiri 1.6.6.2 ) on Ubuntu 14.04 (I use RVM) I needed to do this:

 sudo apt-get install libgmp-dev 

or

 sudo apt-get install libgmp3-dev 
+3
Oct 06 '15 at 9:02
source share

I solved this by installing the xcode dependencies that Nokogiri needed to install:

 xcode-select --install 

After that, install the package again and it should work.

+2
Dec 09 '16 at 23:24
source share

On Ubuntu, try installing the following dependencies:

 sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev 
+2
Jan 30 '17 at 4:17
source share

Since the OP was linking to the bundle install , which I also used, I think it’s worth specifying the Nokogiri installation page , which ultimately showed the most elegant solution (which worked on Mac OS X 10.8.5):

 bundle config build.nokogiri --use-system-libraries bundle install 

This instructs bundler to install nokogiri, as in @kasperite answers

+1
Dec 29 '15 at 21:34
source share

According to the nokogiri installation instructions,

sudo apt-get install zlib1g-dev

solved the problem for me.

+1
May 25 '15 at
source share

The package that did this:

 apt-get install libghc-zlib-dev 

Another possible candidate:

zlib1g-dev from 12.04

found here

+1
Sep 12 '15 at 18:26
source share

I did not receive the same error message as you, but I wanted to note that I finally found as an unusually simple solution to install nokogiri on Ubuntu:

Turns out the nokogiri build process is patch dependent.

Run: sudo apt-get install patch

I was working on a virtual machine (actually it is a stray block), so I have not installed patch yet.

The error I received (after many other things that looked like an error, but actually was just a warning):

 Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2... OK Running patch with /var/lib/gems/1.9.1/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch... Running 'patch' for libxml2 2.9.2... ERROR, review '/var/lib/gems/1.9.1/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened. 

I deleted the log for now (this was in my terminal session), but the patch.log file mentioned above was absurdly simple; he just said something like patch not found .

Boy, I felt stupid for all the digging around, I did the installation of libraries trying to fix it! :)

0
Oct 29 '15 at 18:07
source share

install gcc first

in * buntu: apt-get install gcc

after that, U can request most dev libs such as libxml2 / zlib / etc. see the build log (path in my case): / var / lib / gems / 2.3.0 / extensions / x86_64-linux / 2.3.0 / nokogiri-1.6.8.1 / mkmf.log for a line like - fatal error: zlib. h: No such file or directory

0
Oct 11 '16 at 9:15
source share

To take an amazing answer on Github from dylanjhunt , just in case no one tried it,

Just to add to that, I had a very similar problem that was resolved by updating developer tools.

xcode-select --install

Hoping that someone will see this, that he has not tried to do it yet, and it helps.

0
Mar 27 '17 at 15:29
source share



All Articles