Can't install Nokogiri 1.6.1 under Ruby 2.0.0p353 (rvm-based installation) (OSX Mavericks)?

I tried installing Nokogiri 1.6.1 under Ruby and RVM, but failed the following error:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /Users/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.0.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 /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0)... Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26... OK Running 'configure' for libxslt 1.1.26... ERROR, review 'tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26/configure.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 --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/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete configure task (RuntimeError) from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir' from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute' from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:65:in `configure' from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:108:in `cook' from extconf.rb:101:in `block in <main>' from extconf.rb:131:in `call' from extconf.rb:131:in `block in <main>' from extconf.rb:122:in `tap' from extconf.rb:122:in `<main>' Gem files will remain installed in /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1 for inspection. Results logged to /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out 
+7
ruby osx-mavericks nokogiri
source share
5 answers

Check the grep version and install the latest version via brew:

 $ grep --version grep (BSD grep) 2.5.1-FreeBSD $ brew install grep --default-names # If above fails, you probably need to tap $ brew tap homebrew/dupes $ brew install grep --default-names $ grep --version grep (GNU grep) 2.14.56-1e3d 

From (this nokogiri question) [https://github.com/sparklemotion/nokogiri/issues/935]: "The latest versions of OSX ship with BSD grep, and older versions have GNU grep, and your build script may require GNU grep "

A comment is stolen from Maverick and is duplicated here as an answer, not a comment, because I have already encountered this problem several times and would like to save someone else a headache. = X

+7
source share

You can try the solution that I have used so far to fix the same ...

Remove all old libxml-ruby and nokogiri

use the command below for the same

 sudo gem uninstall nokogiri libxml-ruby 

then you can try the nokogiri version, there is a problem. This should work just fine.

 sudo gem install nokogiri -v '1.6.1' 

A very similar answer, which Dan reported, but has changed a bit. Thanks.

+3
source share

I wrote a message about this after I dealt with him myself. No need for homegrown.

There were several problems that I encountered, the first of which is that development tools cannot be found, and the second is too old libxml.

Run the following commands in rubyconsole:

 $ sudo xcode-select -switch /Library/Developer/CommandLineTools $ gem uninstall nokogiri libxml-ruby $ gem install nokogiri 
0
source share

It turned out that there is a slightly simpler solution:

Delete this line in the ~/.bashrc or ~/.bash_profile ~/.bashrc :

 GREP_OPTIONS="--color=always" 

with this:

 export GREP_OPTIONS="--color=auto" 

This way you will not need to install any duplicates. Thanks MrPowers @Nokogiri Issues .

0
source share

manually. / configure "include" and "lib" locations helped me. The original libxml2 layout is a bit strange, so I got the same options:

gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib

Of course, version numbers depend on what is actually installed . at the time of this writing, the version was in brew.

in my case /usr/local/Cellar/libxml2/2.9.1/include/libxml2 contains one directory named libxml and /usr/local/Cellar/libxml2/2.9.1/lib contains libxml2.2.dylib libxml2.a libxml2.dylib pkgconfig xml2Conf.sh : this is what the script is looking for, no other combination has compiled it using system libraries.

using homebrew nokogiri can be installed without the outdated and incompatible libxml2 and libxslt libraries, as indicated in this gist . working fine and fast for me.

-one
source share

All Articles