ponkiti's blog

主に自分用、イベント参加メモや備忘録として利用

An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.

久しぶりにRails Tutorial 3章のおさらいをしようしてbundle updateすると、前回と同じようなメッセージが出てしまった。

前回と同様に下記を実行したのだが、bundle updateで失敗してしまう。

$ sudo yum install libxml2-devel libxslt-devel
$ gem install nokogiri

$ bundle update
(省略)
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling.

メッセージの指示通りにgem install nokogiri -v '1.6.5'してみたが、やはりエラーのまま。
しかも前回からnokogiriのバージョンが上がっている。

解決方法

システムのライブラリーを使用するように設定する。

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

上記の設定をするだけで解決!

$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
(省略)
Your bundle is updated!
Gems in the group production were not installed.

$ bundle install
(省略)
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

参照