Created
January 3, 2017 17:30
-
-
Save sobstel/f6a490d854a2e5a214c3f2cd9c366032 to your computer and use it in GitHub Desktop.
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `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 |
Thank you!! The one-liner helped me get out of nokogiri hell on MacOS when doing Rails dev. (MacOS 10.14)
thanks!
thanks
If using bundle to install gem, you can run below:
bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries
bundle install
Thank you! This helped me
Thanks for this...
for me libxml2 was here: /usr/local/opt/libxml2/include/libxml2
so gem install nokogiri -v '1.6.8.1' -- --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --use-system-libraries
worked for me
Nokogiri offical manual helps: https://nokogiri.org/tutorials/installing_nokogiri.html
If using bundle to install gem, you can run below:
bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries bundle install
this helped.
Thanks.
<3
Yes
On MacOS Catalina and nokogiri 1.6.8 it didn't help.
I needed to run:
brew upgrade libxml2
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
gem install nokogiri -v '1.6.8'
when using bundler and brew the correct flag are :
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2
no need to export PKG_CONFIG_PATH
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
Works on macOS 10.13.6.