Install xcode command line tools (or check if they're already installed)
xcode-select --install
Do we have libxml installed already?
xsltproc --version
(A libxml version of "20904" means "2.9.4")
Try building the gem against the system libxml headers. Configure bundler like so.
bundle config --global build.libxml-ruby --with-xml2-include=`xcrun --show-sdk-path`/usr/include/libxml2
bundle install
Failing on the libxml-ruby gem?
Try libxml with homebrew (it will be installed in addition to the system libxml):
brew install libxml2
brew link --force libxml2
Check where it installed it (normally /usr/local/opt/libxml2)
brew --prefix libxml2
Add it to your path by editing your ~/.zshrc
file. Add this line on the end:
export PATH="/usr/local/opt/libxml2/bin:$PATH"
Configure bundler like so and try the build again.
bundle config --global build.libxml-ruby --with-xml2-include=`brew --prefix libxml2`/usr/include/libxml2
bundle install
Or try to install the libxml-ruby gem more directly.
gem install libxml-ruby -- --with-xml2-dir=`brew --prefix libxml2` --with-xml2-config=`brew --prefix libxml2`/bin/xml2-config
The above is an agglomeration of tips I've found on sites listed below. I think ideally we would offer more commands/tips to help people check which bits are working step-by-step as they go along. It's useful to think about how to get it working for someone with a fresh macbook, and also for someone with a mess of aborted attempts at installing. Suggestions welcome!
- twilio/twilio-ruby#315
- https://bl.ocks.org/SunDi3yansyah/c84e87165260a3ef81e0bfa4c5989514
- https://stackoverflow.com/questions/32466606/why-arent-gem-and-bundle-using-the-same-libxml2
- https://stackoverflow.com/questions/26878263/libxml2-missing-mac-os-x-10-10
- https://stackoverflow.com/questions/11706007/libxml2-and-libxml2-dev-on-osx
- https://dev.to/okuramasafumi/installing-libxml-ruby-on-macos-1d6m
- https://stackoverflow.com/questions/53222641/bundle-install-fails-to-install-libxml-ruby