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?
run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.
A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile .
Imagine a tool and you most probably have it in your Ruby kit. One of the best gems for Ruby on Rails is Nokogiri which is a library to deal with XML and HTML documents. The most common use for a parser like Nokogiri is to extract data from structured documents.
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"
bundle config --global build.nokogiri --use-system-libraries
Saves configuration to $HOME/.bundle/config
(this path is configurable), so that it is shared by all projects.
The --global
parameter is default, hence one may omit it.
bundle config --local build.nokogiri --use-system-libraries
Saves configuration to <project_root>/.bundle/config
, so that it is confined to gemfiles contained in this directory.
bundle config --delete build.nokogiri
Removes build.nokogiri
setting from both global and local configuration files.
Bundler docs: https://bundler.io/man/bundle-config.1.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With