Installing Nokogiri from a Gemfile on Mojave

November 14, 2018

Another MacOS and another struggle through installing nokogiri. Most places online recommend using --with-xml2-include and --use-system-libraries during gem install, but if you're installing from a Gemfile using bundle install, it can sometimes be a little trickier.

To enable passing args like this to a gem installed from a Gemfile, we can use Bundler Config. The magic command to run before bundle install on Mojave is:

bundle config build.nokogiri --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2   --use-system-libraries
Picture of me with a corgi

Noah Gilmore

Hello! I'm Noah, a software developer based in the San Francisco bay area. I focus mainly on iOS, Apple platform development, and full stack web development.

  • 💻 I'm writing a macOS editor for Atlassian Confluence called Fluency
  • 📱 I wrote an app which lets you create transparent app icons called Transparent App Icons
  • 🧩 I made a puzzle game for iPhone and iPad called Trestle
  • 🎨 I wrote a CoreImage filter utility app for iOS developers called CIFilter.io
  • 👋 Please feel free to reach out on Twitter