Error installing Nokogiri gem on Mac OS X - ruby

I was trying to install a connector for Rally and bugzilla on my Mac OSx. While running the install script, it tries to install the gems and it looks for the libxml2 which is already present on my machine.
This happens when it tries to install nokogiri.
This is the transcript:
Building native extensions with: '--use-system-libraries'
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 ./siteconf20150121-48754-wgouyu.rb extconf.rb --use-system-libraries
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.4.0/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 /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.4.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.4.0/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 /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.4.0/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
` libxml2 is missing. please visit http://nokogiri.org/tutorials /installing_nokogiri.html for help with installing dependencies.`
-----
*** 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
--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-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-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-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-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
--with-iconvlib
--without-iconvlib
--with-xml2lib
--without-xml2lib
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
I tried so many options like installing the command line tools by running the below command.
xcode-select --install
Adding the symbolic links to gcc compliler
sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
I have been struggling for the past two days. Any help is highly apperciated.

If you are using brew use this in the terminal:
brew unlink gcc-4.2 # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
If this didn't work please check "Installing Nokogiri on OSX 10.10 Yosemite"

Solved the issue with the command
sudo ARCHFLAGS="-arch x86_64" gem install nokogiri -v '1.6.1'
thanks for the link pointed out by mohamed abd.

This worked for me:
sudo gem install nokogiri --no-rdoc --no-ri

Related

Install Nokogiri on Yosemite 10.10.3

I have:
Mac OS X Yosemite 10.10.3
MacPorts (not Brew)
Ruby 2 in system (not RVM)
I want to install Nokogiri and tried:
port install nokogiri
and got:
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
./siteconf20150323-30174-1mqhl4i.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... yes checking for iconv... yes
************************************************************************ IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2 with the
following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************ Extracting libxml2-2.9.2.tar.gz into
tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2... OK Running patch with
/Library/Ruby/Gems/2.0.0/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... OK Running patch with
/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK Running 'configure' for
libxml2 2.9.2... OK Running 'compile' for libxml2 2.9.2... ERROR,
review
'/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2/compile.log'
to see what happened.
*** 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 --with-zlib-dir --without-zlib-dir
--with-zlib-include --without-zlib-include=${zlib-dir}/include
--with-zlib-lib --without-zlib-lib=${zlib-dir}/lib
--enable-cross-build --disable-cross-build
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in
`block in execute': Failed to complete compile task (RuntimeError)
from
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in
`chdir' from
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in
`execute' from
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:70:in
`compile' from
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:110:in
`cook' from extconf.rb:278:in `block in process_recipe' from
extconf.rb:177:in `tap' from extconf.rb:177:in `process_recipe' from
extconf.rb:475:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in
/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection. Results
logged to
/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.6.2/gem_make.out
I tried:
gem install nokogiri -- --use-system-libraries
and got:
Building native extensions with: '--use-system-libraries' 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
./siteconf20150323-34882-16v74a8.rb 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... no Building nokogiri using system libraries. checking for xmlParseDoc()
in libxml/parser.h... no checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
----- libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** 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 --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 --with-xml2lib
--without-xml2lib --with-libxml2lib --without-libxml2lib
extconf failed, exit code 1
Gem files will remain installed in
/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection. Results
logged to
/Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.6.2/gem_make.out
I tried:
port install libxml2
and got:
---> Computing dependencies for libxml2
---> Cleaning libxml2
---> Scanning binaries for linking errors
---> No broken files found.
What else I can do to install Nokogiri?
Because MacPorts (and other similar package managers) install packages in non-standard locations, it cannot automatically determine the path to libxml2. The warning in your first attempt provided information on how to resolve this:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
You said that you tried gem install nokogiri -- --use-system-libraries. The Nokogiri documentation suggests that you need to add either of the following two options:
--with-xml2-config - Path to the xml2-config binary (try which xml2-config)
--with-xml2-dir - Path to the libxml2 base installation directory
If you’ve got libxml2 and/or libxslt installed in a nonstandard place
(read as “not /opt/local, /usr/local, /usr or the standard Ruby
directories”), you can use command-line parameters to the gem install
command to grease the wheels.
gem install nokogiri -- \
--use-system-libraries \
--with-xml2-dir=/path/to/dir \
--with-xslt-dir=/path/to/dir
This page gives appropriate commands for various package managers, including MacPorts:
gem install nokogiri -- \
--with-xml2-include=/opt/local/include/libxml2 \
--with-xml2-lib=/opt/local/lib \
--with-xslt-dir=/opt/local
Check to see if Xcode is installed on your machine then run xcode-select --install in the terminal. This should do the trick and allow you to run sudo gem install rails

Cannot install Ruby gem libxslt-ruby on Mac cause it does not find libxml2

I've installed libxml2 and libxslt through Brew on my Mac but
gem install libxslt-ruby -- --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include --with-xslt-include=/usr/local/opt/libxslt/include --version=1.1.1
or
gem install libxslt-ruby -- --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.1 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --version=1.1.1
throws
Building native extensions. This could take a while...
/Users/gawlim/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/Cellar in PATH, mode 040777
ERROR: Error installing libxslt-ruby:
ERROR: Failed to build gem native extension.
/Users/gawlim/.rbenv/versions/1.9.3-p484/bin/ruby extconf.rb --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include --with-xslt-include=/usr/local/opt/libxslt/include -v 1.0.8
checking for ruby/io.h... yes
checking for inflate() in -lz... yes
checking for iconv_open() in -liconv... yes
checking for xmlXPtrNewRange() in -lxml2... yes
checking for libxml/xmlversion.h... no
checking for libxml/xmlversion.h in /opt/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** 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=/Users/gawlim/.rbenv/versions/1.9.3-p484/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--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
--with-xml2-include=${xml2-dir}/include
--with-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--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-zlib
--without-zlib
--with-iconvlib
--without-iconvlib
--with-xml2lib
--without-xml2lib
extconf failure: %s
need libxml2.
Install the library or try one of the following options to extconf.rb:
--with-xml2-dir=/path/to/libxml2
--with-xml2-lib=/path/to/libxml2/lib
--with-xml2-include=/path/to/libxml2/include
Although an old question, I though I'd share the solution I found. Before installing the libxslt-ruby gem, run the following:
gem update --system
Here's the documentation for that command:
http://guides.rubygems.org/command-reference/#gem-update
As of April 2022, the following worked for me:
brew install libxslt
gem install libxslt-ruby -v '1.2.0' -- --with-xslt-include="$(brew --prefix libxslt)/include/libxslt" --with-exslt-include="$(brew --prefix libxslt)/include/libexslt"

Nokogiri 1.5.9 gem does not install on Mac OS X Mavericks?

Last night my system updated to Maverick and now I can not install Nokogiri from my gemfile. It complains that it can not find libxml2, but Maverick ships with libxml2. I have also tried
brew install --development libxml2
And:
brew install --development libxslt
and I still see the same error message. I have pasted the error messages below, can someone take a look and tell me what I should try next?
mapte:config-renderer mapte$ gem install nokogiri -v '1.5.9'
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/local/var/rbenv/versions/1.9.2-p180/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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/var/rbenv/versions/1.9.2-p180/bin/ruby
--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-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-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-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-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
Gem files will remain installed in /usr/local/var/rbenv/versions/1.9.2-
p180/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.9 for inspection.
Results logged to /usr/local/var/rbenv/versions/1.9.2-p180/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out
For me I had to install the developer tools:
xcode-select --install
Then be sure to open the xcode app and accept the license.
I tried to do it from the command line but it didn't work.
The first thing I would check is that your /usr/include is not empty or missing libxml2.h and consider symlinking or otherwise exposing your Xcode SDK /usr/include to the hombrew process:
The app store version is below, but feel free to adjust the path for beta/pre-release/GM/older versions of Xcode you may wish to use is providing a parser.h file:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2/libxml/parser.h
Next step would to be sure homebrew is up to date with the typical three step dance:
brew update
brew outdated
brew upgrade
At that point, you might need to actually list your exact error message from the mkmf.log file according to the output you pasted in the question.

troubles with nokogiri gem on mountain lion using bundler

I can SUCCESSFULLY install nokigiri using
sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
however when I run "bundle install" I have libxml2 problems. My question is: how do I get nokogiri to install via bundler?
here is my "bundle install" output:
Installing nokogiri (1.6.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2
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/philswenson/.rvm/gems/ruby-1.9.3-p448#3rdrevolution/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/philswenson/.rvm/gems/ruby-1.9.3-p448#3rdrevolution/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
--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-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--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-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
--with-xml2lib
--without-xml2lib
Gem files will remain installed in /Users/philswenson/.rvm/gems/ruby-1.9.3-p448#3rdrevolution/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/philswenson/.rvm/gems/ruby-1.9.3-p448#3rdrevolution/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
Could someone point me in the right direction?
Thanks!
You shouldn't be using sudo if you're using RVM or similar Ruby versions manager.
This works on the latest Xcode CLT, mountain lion and mavericks, and nokogiri 1.6.1
Interim solution 0
exactly nokogiri's patches as brew formulas libxslt and libxml2
curl -L https://gist.githubusercontent.com/steakknife/8969368/raw/install_nokogiri_brew_osx.sh | bash
if you dont trust https pipe to shell, here's the script raw url. [gist url]
Way faster and gives a known good, keg-only copy of libiconv and nokogiri's libxml2 and libxslt. System libxml2 isn't touched.
Interim solution 1
This takes a couple minutes and eats up 100 MiB+ when installed.
gem install nokogiri
Either way, libxml2 needs to become more stable or it's a de-facto fork and more work for everyone.
Don't bother link-ing libxml2 or libxslt, sudo anything, or make install libiconv either, these are unnecessary and fragile.

What is a robust installation process for Nokogiri (on Ubuntu)?

I tried to install Nokogiri on my Ubuntu 12.04 system, and got an error that said "libxslt is missing", but the libxslt-dev and libxml2-dev are installed.
Is there a robust installation process? How can I check the links to dependent libraries?
I used RVM, and the RVM pkg is installed too.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/victor/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... no
-----
libxslt is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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=/home/victor/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
--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-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-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-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-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-libiconv-config
--without-libiconv-config
--with-xml2lib
--without-xml2lib
--with-xsltlib
--without-xsltlib
Gem files will remain installed in /home/victor/.rvm/gems/ruby-1.9.3-p125#dradis/gems/nokogiri-1.5.4 for inspection.
Results logged to /home/victor/.rvm/gems/ruby-1.9.3-p125#dradis/gems/nokogiri-1.5.4/ext/nokogiri/gem_make.out
enter code here
I have also experienced the same problem with rvm, even though I had done the following, as per documentation:
sudo apt-get install libxslt-dev libxml2-dev
rvm pkg libxml2 and rvm pkg libxslt
The only way I could get this solved was, after a lengthy investigation:
Uninstall the ruby installation: rvm remove 1.9.3
Delete all libxslt* and libxml2* libs from ~/.rvm/usr/lib if you had previously done rvm pkg ...
Reinstall ruby: rvm install 1.9.3
Reinstalling after the apt-get commands seems to be the only way of getting this to work. Also, ensuring the libs installed with rvm pkg don’t interfere helped.
When everything else fails...
If everything else fails and you absolutely need the gem installed, you can also rebuild nokogiri by applying a simple patch — provided that you have all build tools installed, and with the caveat that this will install the latest and potentially unstable code:
git clone git://github.com/sparklemotion/nokogiri
get patch from this gist and save it as x86_64.patch in the nokogiri folder.
Apply patch: patch -p1 < x86_64.patch
Rebuild: rake native gem — this should build the gem in the pkg/ folder
Install the gem using gem install pkg/nokogiri-<version>-x86_64-linux.gem
I'm pretty new to ruby, but this...
gem install nokogiri -v '1.5.2' -- --with-xml2-lib=/usr/lib/i386-linux-gnu --with-xml2-include=/usr/include/libxml2 --with-xslt-lib=/usr/lib/i386-linux-gnu --with-xslt-include=/usr/include/libxslt
...worked for me on Ubuntu 12.04. (Or, anyway, it satisfied the nokogiri dependency and got me one step closer to what I'm really trying to accomplish.) I thought it might have messed up my RVM magic, but nokogirl-1.5.2 is definitely sitting there in ~/.rvm/ruby-1.9.3-p194/gems, so...maybe it's all good?
I was having this issue on Ubuntu 13.04.
I had tried everything that you find all over the place online. Making sure packages listed on the Nokogiri install page are present, etc etc.
The only thing that eventually did it for me was installing libsxlt from source. After that everything worked perfectly.
I had to use gem install nokogiri -- --with-iconv-dir=/usr/lib/ruby/1.9.1/x86_64-linux
sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby
sudo apt-get install libxslt-dev libxml2-dev
?

Resources