Bundle install fails to install libxml-ruby

I manage to fix this with the help of a colleague, if anybody else encounter this problem:

gem install libxml-ruby -v '2.9.0' -- --use-system-libraries --with-xml2-dir=/usr/local/Cellar/libxml2/2.9.8/include/libxml2/libxml/ --with-xml2-config=/usr/bin/xml2-config

Replace '2.9.0' with the libxml version that you need!


These steps worked for me (source)

brew install libxml2
bundle config --global build.libxml-ruby --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config"

then bundle install worked as expected


It solved for me in mac by running

gem install libxml-ruby -v '3.0.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