I recently faced with error when reinstalled ruby and run bundle
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
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.
...
Install the library or try one of the following options to extconf.rb:
--with-xml2-config=/path/to/xml2-config
--with-xml2-dir=/path/to/libxml2
--with-xml2-lib=/path/to/libxml2/lib
--with-xml2-include=/path/to/libxml2/include
Tried a lot of solutions from the Internet, but really helpuf was:
gem install libxml-ruby -v '3.1.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include
PS. Helped second time again, when I upgraded ruby with rvm