How to "gem install nokogiri -- --use-system-libraries" via Gemfile

s2t2 picture s2t2 · Apr 21, 2015 · Viewed 7.1k times · Source

There is a known error installing the latest version of Nokogiri. The workaround is to manually install using

gem install nokogiri -- --use-system-libraries

But how can this be done via the Gemfile?

Answer

infused picture infused · Apr 21, 2015

Run

bundle config build.nokogiri --use-system-libraries

After running this command, every time Bundler needs to install the nokogiri gem, it will pass along the flags you specified.

It remembers this setting by adding an entry to your ~/.bundle/config file:

---
BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries"