Instantly share code, notes, and snippets.

Embed
What would you like to do?
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
# `ERROR: Error installing nokogiri:
# ERROR: Failed to build gem native extension.
#
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --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.
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
# *** 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.`
gem install nokogiri -- \
--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 \
--use-system-libraries
# copy/paste one-liner
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries
@JeffreyMFarley

This comment has been minimized.

JeffreyMFarley commented Oct 31, 2017

Thank You!

@bramski

This comment has been minimized.

bramski commented Dec 18, 2017

So much happiness.

@tclaus

This comment has been minimized.

tclaus commented May 15, 2018

Thanks, works on OSX 10.13.4 like a charm. I added a " -v '1.7.2' " right after 'nokogiri' for my needs.

@VladRose

This comment has been minimized.

VladRose commented Jul 5, 2018

You are the best of the best. THX very much!

@suya55

This comment has been minimized.

suya55 commented Aug 1, 2018

Thank you so much!!

@arvsr1988

This comment has been minimized.

arvsr1988 commented Aug 8, 2018

I used brews libxml2 as I got this error while using the libxml2 with macos

ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

this is what i did finally

brew install libxml2
gem install nokogiri -v '1.6.8' --   --with-xml2-include=/usr/include/libxml2   --use-system-libraries
@fbukevin

This comment has been minimized.

fbukevin commented Sep 12, 2018

Thanks!

gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2   --use-system-libraries

Works on macOS 10.13.6.

@roberttravispierce

This comment has been minimized.

roberttravispierce commented Nov 2, 2018

Thank you!! The one-liner helped me get out of nokogiri hell on MacOS when doing Rails dev. (MacOS 10.14)

@lisovskyvlad

This comment has been minimized.

lisovskyvlad commented Nov 28, 2018

thanks!

@xiaohui-zhangxh

This comment has been minimized.

xiaohui-zhangxh commented Dec 13, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment