sudo gem install nokogiri Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /Users/sajeev86/.rvm/rubies/ruby-1.8.7-p352/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.
I can't get Nokogiri to install. This has been taxing me for a while now. I've installed the dependencies via MacPorts and Homebrew as well.
I've got a feeling the right directories are not pointed to each other? But haven't a clue how to fix.
In Mavericks, installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1
before installing the gem did the trick for me.
Summarising:
If previously installed, uninstall the gem:$ gem uninstall nokogiri
Use Homebrew to install libxml2
, libxslt
and libiconv
:$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
Absolutely none of the other answers here worked for me.
On the latest version of Mavericks, the only method that succeeded for me was the following:
$ brew install libxml2 libxslt libiconv $ sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With