Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nokogiri fails to install osx

I saw a lot of questions of this kind but I have a little different situation, so i'm doing bundle install and got this:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150109-25233-1jiriou.rb extconf.rb --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
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 iconv using --with-iconv-* flags... no
checking for iconv... no
-----
libiconv 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
    --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

extconf failed, exit code 1

Gem files will remain installed in /var/folders/sk/x8m9btmj1g58c906v0z3k2br0000gq/T/bundler20150109-25233-o53u4y/nokogiri-1.6.5/gems/nokogiri-1.6.5 for inspection.
Results logged to /var/folders/sk/x8m9btmj1g58c906v0z3k2br0000gq/T/bundler20150109-25233-o53u4y/nokogiri-1.6.5/extensions/universal-darwin-14/2.0.0/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.

I have libiconv installed, I tried in this way gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/ gem installs ok but than i try to bundle I got the same error again the same situation is when I try to do gem install nokogiri -v '1.6.5' the installation is ok, I can see the gem in the list of gems but seems like bundler is not seeing it, I tried to include it in my gem file with this specific version but still have this error

like image 465
maki Avatar asked Jan 08 '15 22:01

maki


3 Answers

This worked for me: http://www.nokogiri.org/tutorials/installing_nokogiri.html#using_nonstandard_libxml2___libxslt_installations

gem install nokogiri -- \
    --use-system-libraries \
    --with-xml2-config=/usr/bin/xml2-config \
    --with-xslt-config=/usr/bin/xslt-config

And then bundle update

like image 167
cbertelegni Avatar answered Oct 06 '22 20:10

cbertelegni


You can use bundle config to set that path:

bundle config build.nokogiri "--with-iconv-dir=/usr/local/Cellar/libiconv/1.14/"
bundle install
like image 21
Gergo Erdosi Avatar answered Oct 06 '22 19:10

Gergo Erdosi


This works for me bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"

Run this command to set the config before bundle install

I got this solution from https://github.com/sparklemotion/nokogiri/issues/1099

like image 4
newBike Avatar answered Oct 06 '22 19:10

newBike