LoginSignup
4
3

More than 3 years have passed since last update.

bundle install時にnokogiriエラー(nokogiriのバージョン1.10.4)

Last updated at Posted at 2019-08-27

Railsで新しいプロジェクトを作ろうと、
bundle install —path vendor/bundle
を実行した際に、nokogiriのインストールでエラーが発生しました。

環境

$ brew --version
Homebrew 2.1.10
Homebrew/homebrew-core (git revision ea340; last commit 2019-08-20)
$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
$ gem --version
3.0.3

エラーメッセージ

エラーメッセージの中から原因と対処法が記された部分を抜粋します。


IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.33
with the following patches applied:
    - 0001-Fix-security-framework-bypass.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

対処法

Nokogiriのインストールに必要なlibxml2ライブラリというものがNokogiriの中に同梱されているのですが、これをsystem内にあるlibmxl2を利用するように設定するとうまくいくとのことです。
今回はbundleを使ってインストールするので、下記のコマンドでうまくいきました。

$ bundle config build.nokogiri --use-system-libraries
$ bundle install —path vendor/bundle

まとめ

どうやら古より伝わるエラーらしく、様々な対処法がネットで報告されています。
再発率の高い厄介なエラーですね…

今回はエラーメッセージに対処法がそのまま載っていました。ググることも大事ですが、その前にエラーメッセージや公式リファレンスに目を通すことが大事ですね。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3