Skip to content

Instantly share code, notes, and snippets.

@wbotelhos
Last active February 6, 2020 14:09
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wbotelhos/5070bf5ae4d4c75f02ee849659f8c4c4 to your computer and use it in GitHub Desktop.
Save wbotelhos/5070bf5ae4d4c75f02ee849659f8c4c4 to your computer and use it in GitHub Desktop.
ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
xcode-select --install
gem install nokogiri
Copy link

ghost commented May 12, 2017

Thank you for this!

@praweb
Copy link

praweb commented Jun 8, 2017

Thanks for this ..Its saved my day

@ridiculous
Copy link

Yasss!! Thank you. This was the 3rd ranked search result 😆

@sleekweasel
Copy link

Alternatively:

LIBXML2_DIR=/usr/local/opt/libxml2/include/libxml2
[ -e $LIBXML2_DIR ] || brew install libxml2
gem install nokogiri -v '1.6.8.rc3' -- --with-xml2-dir=LIBXML2_DIR

@peterwake
Copy link

Thanks for this - it worked!

@gerardosandoval
Copy link

Worked nokogiri/nokogubmo 👍 thx!

@nlayja
Copy link

nlayja commented Jun 12, 2018

¡does not recognize! other option, :)

C:\Ruby24-x64\code\test1>xcode-select --install
"xcode-select" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

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.

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=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--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-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-pkg-config
--without-pkg-config
--with-override-variables
--without-override-variables
--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-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/nokogiri-1.8.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/nokogiri-1.8.2 for inspection.
Results logged to
C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/nokogiri-1.8.2/gem_make.out

An error occurred while installing nokogiri (1.8.2), and Bundler cannot
continue.
Make sure that gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/' succeeds before bundling.

In Gemfile:
rails was resolved to 5.2.0, which depends on
actioncable was resolved to 5.2.0, which depends on
actionpack was resolved to 5.2.0, which depends on
actionview was resolved to 5.2.0, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri

@Zerquix18
Copy link

Is this for Linux?
I get xcode-select: command not found

@noahsark769
Copy link

No, this is for macOS

@elja
Copy link

elja commented Dec 5, 2018

@Danielshow
Copy link

Life saver, thanks a bunch

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