Error to install Nokogiri on OSX 10.9 Maverick?
Solution 1
I found this log and saw that gcc-4.2 was not found:
package configuration for libxslt
cflags: -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2
ldflags: -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib
libs: -lxslt -lxml2 -lz -lpthread -liconv -lm -lxml2
package configuration for libxml-2.0
cflags: -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2
ldflags: -L/usr/local/Cellar/libxml2/2.9.1/lib
libs: -lxml2
package configuration for libiconv is not found
"/usr/bin/gcc-4.2 -o conftest -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin11.4.0 -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2 -I/usr/local/Cellar/libiconv/1.14/include -I/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/include -I/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/include -I/Users/ericcamalionte/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DNOKOGIRI_USE_PACKAGED_LIBRARIES -DNOKOGIRI_LIBXML2_PATH='"/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0"' -DNOKOGIRI_LIBXSLT_PATH='"/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26"' -I/usr/local/Cellar/libxslt/1.1.28/include -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2 -I/usr/local/Cellar/libxml2/2.9.1/include/libxml2 conftest.c -L. -L/Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib -L/usr/local/Cellar/libiconv/1.14/lib -L/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/lib -L/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/lib -L/Users/ericcamalionte/.rvm/usr/lib -L. -Wl,-rpath,/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0/lib -Wl,-rpath,/Users/ericcamalionte/.rvm/gems/ruby-1.9.2-p320@dns-panel/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26/lib -L/usr/local/Cellar/libxslt/1.1.28/lib -L/usr/local/Cellar/libxml2/2.9.1/lib -L/usr/local/Cellar/libxml2/2.9.1/lib -lxslt -lxml2 -lz -lpthread -liconv -lm -lxml2 -lxml2 -lruby.1.9.1-static -lpthread -ldl -lobjc "
sh: /usr/bin/gcc-4.2: No such file or directory
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
To solve this problem I intalled apple-gcc42 using homebrew brew install apple-gcc42
and created a symlink to my /usr/bin :
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc-4.2
Solution 2
You can also install Nokogiri on Mac OS X 10.9 Mavericks with full XCode Install using:
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
Update
For those using Yosemite the following command will work:
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
or, it might actually be in your MacOSX10.11.sdk
folder (mine was as of 18-Sep-2015) anyways, so even if you are not yet fully up to El Capitan, I had recently updated XCode and you may need to use the El Capitan SDK path, which follows next:
Update
For those using El Capitan the following command will work:
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries
Update
For those using Sierra the following command will work:
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 --use-system-libraries
Solution 3
After navigating the animated GIFs here, all that I had to do was simply xcode-select --install
and the gem install nokogiri
worked fine.
Solution 4
If you're running Xcode 5.1, the command line tools don't work for nokogiri 1.6.1. You'll need to download the Late october 2013 tools from Apple. Once you do that run
sudo xcode-select -s /Library/Developer/CommandLineTools/
to set up your machine to use the Xcode 5.0.X command line tools, then run
gem install nokogiri
If you want to reset your command line tools to the Xcode.app version afterward run
sudo xcode-select -r
Or, another thing you can do is add the flag to ignore unknown command line arguments. Then the install looks like this:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri
Solution 5
This is what worked for me on OSX Mavericks:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri -v '1.6.1' --verbose --no-ri --no-rdoc
Related videos on Youtube
Comments
-
squiter about 4 years
I upgraded my OSX (Lion) to Mavericks and I can't install Nokogiri for my projects.
I already install XCode 5.0.1, Command Line Tools (using
xcode-select --install
), and already installed libxml2 from Homebrew and I am still having problems.The error is:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb checking for libxml/parser.h... *** 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/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/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 /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:254:in `open' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for' from /Users/ericcamalionte/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/mkmf.rb:852:in `find_header' from extconf.rb:116:in `<main>' Gem files will remain installed in /Users/ericcamalionte/Locaweb/code/dns-panel/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.9 for inspection. Results logged to /Users/ericcamalionte/Locaweb/code/dns-panel/vendor/bundle/ruby/1.9.1/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out An error occured while installing nokogiri (1.5.9), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.
I installed libxml2, libxslt and libiconv from Homebrew, and set the params to install Nokogiri, but don't work too.
I can't find what's wrong in my enviroment, can you help me?
-
davidcondrey over 9 yearspossible duplicate of Error installing nokogiri 1.6.0 on mac (libxml2)
-
moander almost 9 yearsTry opening xcode and accept the EULA/license.
-
-
David Portabella over 10 yearsthis didn't solve the issue for me, i still have the same error message :(
-
David Portabella over 10 yearsI completely uninstalled rvm and ruby (from brew), installed again, and it worked.
-
trojanfoe over 10 yearsDoes it not compile using
clang
? -
trojanfoe over 10 yearsHow did you compile
apple-gcc42
then? It must be easier to use the "default" compiler than to install a new (old) one? -
squiter over 10 yearsSo, I just run
brew install apple-gcc42
.. and just works. That command don't work for you? -
Quickredfox over 10 yearsI ran
xcode-select --install
before the brew install and all works now. -
darkmoves over 10 yearsI had to be very meticulous with the filepaths. It took me multiple tries to correctly construct the commands.
-
squiter over 10 yearsI don't have a paid account and I was installed the command-line tools. I installed using terminal, but a friend of mine installed using that download page, and he doesn't have a paid account too.
-
shinesecret over 10 yearsI Agree with you. Same thing happened with me till 24th Nov, 2013. However if you go to that page now and try to access it, it will give you this error. Weird thing is you login with your credentials but it will keep you login as guest. This is the message I get on page with my account: Apple Developer Program Big Warning We are unable to process your request. Please go back to the previous page, or quit your browser and try your request again. If you require assistance, please contact Apple Developer Support.
-
Justin over 10 yearsPlease post the stuff here - links are liable to be broken (see the guidelines)
-
darkmoves over 10 yearsHere's a link to another solution to the issue of an incorrect libxml version.
-
Lucy Bain about 10 years@BrunnoDosSantos where did you find the log? I checked my
gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
but it just had the same error message as in your question. -
squiter about 10 years@LucyBain I realy don't remember.... but I think that log file was in same directory as gem_meake.out...
-
Tim Stephenson about 10 yearsWhen I ran brew install apple-gcc42 I gat a warning that it was already installed. Running brew uninstall apple-gcc42 and then installing it did the trick for me.
-
Pop-A-Stash about 10 yearsNot for me: "libxml2 is missing. please visit nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies." Still getting same error.
-
Richard almost 10 yearsIt helped me, although I do echo the sentiment of posting the answer here, rather than in a link :)
-
Tizón almost 10 yearsThank you, works for me! PS: very good jasdeep.ca/2013/10/installing-nokogiri-fails-os-x-mavericks
-
superluminary almost 10 yearsDoh, yes, I had neglected to install the XCode command line tools on my clean Mavericks install.
-
sparrow almost 10 yearsPerfect. Exactly what I needed. +1
-
jmg over 9 yearsHad to add --use-system-libraries. Than it worked on a brand new mavericks installation with Xcode 5.1.1 and brew.
-
Volte over 9 yearswould gem install nokogiri -- --use-system-libraries help?
-
Maverick over 9 yearsHad to add the
--use-system-libraries
to get this to work:gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --use-system-libraries
-
Tim over 9 yearsCool. Now that you are using rvm on mavericks try opening vim. SEGV error? Lovely.
-
Brian Hempel over 9 yearsWith bundler, I used
bundle config build.nokogiri --with-iconv-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr
-
Ben over 9 yearsi had a similar issue (an unlinked libiconv). I unlinked libiconv, and reinstalled. brew install libiconv, then gem install nokogirl.
-
Rogerio Chaves over 9 yearsafter googling it for hours, that was the only solution that worked for me, thanks! :D
-
KonstantinK over 9 yearsamazingly this is the only thing in this entire tread that helped me too. thanks!
-
Tod Birdsall over 9 yearsThis worked for me:
gem install nokogiri -- --use-system-libraries
-
PJP over 9 yearsThe problem with this is, using
sudo
with RVM or rbenv will cause problems as root doesn't know where the sandboxed Rubies live. This is covered in the RVM installation page. The OP is using RVM, and usingsudo
would cause Nokogiri to install into Apple's Ruby, not the user's. So, don't do this unless you are SURE you want to install into Apple's Ruby if you're on Mac OS, or into the system Ruby if you're on another *nix. -
PJP over 9 yearsUsing
sudo
will cause Nokogiri to be installed in the only Ruby known by root, which is highly likely to be Apple's installed Ruby unless using Homebrew. Because the OP was using RVM, that means Nokogiri wouldn't be seen by a RVM managed Ruby, and would only compound the problem. Usingsudo
might have worked in this case, but it should not be tried with a RVM or rbenv managed Ruby. RVM specifically says not to do it in the installation documentation. -
PJP over 9 yearsThis is what is considered a Link-only answer which are discouraged on Stack Overflow. Instead of only posting a link to your own site, also summarize the important information in your answer. That way, if the link rots, like they tend to do, the answer will continue to provide some value.
-
Josh about 9 yearsThis worked for me, i tried about 50 SO threads and this was the only one that worked... osx 10.10.3
-
Amax about 9 yearsyou're such a lifesaver!
-
Erik Villegas about 9 yearsThis is the only one that would work for me, on 10.10.3: sudo gem install nokogiri -- --with-iconv-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib --with-iconv-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
-
MattL almost 9 yearsWorked for me on Yosemite too. None of the above answers did.
-
Durul Dalkanat over 8 yearsyou should use this command . open terminal. and Write this command. export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
-
Arian Faurtosh over 8 yearsThis post being updated for El Capitan makes me happy.
-
Philipp over 8 yearsYou may want to update your answer with the more generic command that should work across all OS X versions and Xcode install paths:
gem install nokogiri -- --with-xml2-include=`xcrun --show-sdk-path`/usr/include/libxml2 --use-system-libraries
-
Dex over 8 yearsThe command for El Capitan worked for me as well to install -v '1.6.6.2'. Thank you!
-
Onikoroshi over 7 yearsI couldn't remove the gemset because the folders weren't empty, but reinstalling the gemset (even though there were errors) did! This is the only thing that worked for me!