How to install Nokogiri on Mac OS Sierra 10.12
Open Xcode and, from the menu XCode
-> Preferences
update your Command Line Tools (Xcode 8.0).
Then do:
bundle config build.nokogiri --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
bundle install
or just:
gem install nokogiri -v 1.6.8.1 -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
The more simple solution is to execute:
xcode-select --install
gem install nokogiri
Update
For Mojave I'm using gem install nokogiri -v '1.6.6.2' -- --use-system-libraries
Try install libxml2 first with Homebrew.
brew install libxml2
Then if installing with bundle
bundle config build.nokogiri --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
bundle install
If installing directly with gem
gem install nokogiri -- --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2