Just do IT

思うは招く

railsをbundle installする際のnokogiriでインストールエラーが出る

環境

問題

Gemfile

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem "rails"

これでbundle installすると。

bundle install --path vendor/bundle

nokogiriのところで止まる。

Fetching nokogiri 1.10.7
Installing nokogiri 1.10.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing nokogiri (1.10.7), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.7' --source 'https://rubygems.org/'` succeeds before bundling.

まぁこういった光景はよく見る。 面倒くさがらずにエラーメッセージをよく読んでみる。

IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.10
with the following patches applied:
    - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
    - 0002-Remove-script-macro-support.patch
    - 0003-Update-entities-to-remove-handling-of-ssi.patch
    - 0004-libxml2.la-is-in-top_builddir.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

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

解決策、書いてるやん。

If you are using Bundler, tell it to use the option:

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

「bundlerを使ってるならこれやってよ」とのことなのでやってみる。

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

できました。