LoginSignup
90
84

More than 5 years have passed since last update.

bundle install で nokogiri をインストールしろと言われる解決方法

Last updated at Posted at 2014-08-16

Vagrant内にrbenvでインストールしたRuby環境を使っています。

ある日突然、bundle installが失敗し、nokogiriをインストールしろというメッセージが表示される現象が発生しました。

bundle install でエラーがでて失敗

bundle installを実行しようとしました。

インストールコマンドを実行
bundle install --path vendor/bundle

エラーがでます。

インストールコマンドでエラー
bundle install --path vendor/bundle

略

************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

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

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

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

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
略
An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

先にnokogiriを入れろと言われます。

しかし、ここで単にgem install nokogiriをしてもbundle installはまた失敗します。むしろ、libxmlやnokogiriは既にインストールされている状態なので、なぜnokogiriがインストールできないのか疑問でした。

--use-system-librariesオプションをつける

Bundlerを利用しているので、エラーで出力された説明にあるとおり、--use-system-librariesをつけます。

オプションをつける
bundle config build.nokogiri --use-system-libraries

bundle config で --use-system-librariesオプションを指定してからbundle installを実行します。

再度インストール
bundle install --path vendor/bundle

今度はbundle installがうまくいきました☆(ゝω・)vキャピ

90
84
2

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
90
84