Installing Nokogiri from a Gemfile on Mojave

November 13, 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
Tweet This
Get New Posts Via Email
Picture of me with a corgi

Noah Gilmore

I'm Noah, a software developer based in the San Francisco Bay Area. I focus mainly on full stack web and iOS development

  • 💻 I co-founded Replo, a no-code platform for e-commmerce
  • ✍️ You can read technical posts on my blog
  • 📱 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 / 𝕏