かなりハマったのでメモ。どなたかの参考になれば!
環境:
OS X 10.9.4
ruby 2.0.0p451("$ ruby -v")
homebrew 0.9.5("$ brew -v")
bundle installでエラー、個別にやっても失敗
$ gem install nokogiri
以下のエラーが発生。
An error occurred while installing nokogiri (1.6.0),
and Bundler cannot continue.Make sure that gem install
nokogiri -v '1.6.0' succeeds before
bundling.
Nokogiriのサイトの手順に沿ってもエラー
(http://nokogiri.org/tutorials/installing_nokogiri.html)
$ brew install libxml2 libxslt
$ brew link libxml2 libxslt
$ wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
(※直接URLを叩いてtar.gzファイルをDLし、/usr/local/Cellar/libiconv/に置きました)
$ tar xvfz libiconv-1.13.1.tar.gz
$ cd libiconv-1.13.1
$ ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
$ make
$ sudo make install
$ sudo gem install nokogiri --
--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
以下のエラーが発生
checking for iconv_open() in iconv.h... yes
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers. Check the mkmf.log file for more details. You mayneed configuration options.
iconv.hは認識されてるけど、iconv_open()でエラー!?mkmf.logを見たりしつつ、わわからないなりに色々と調べてみたが、とりあえずはこちらのコマンドで解決。
XcodeのCommand Line Toolsがインストールされてませんでした。。
単純なミスだけどなかなか気付けず、ハマってしまいました。
$ xcode-select --install
その後、先ほどのコマンドでNokogiriのインストールできました。
$ sudo gem install nokogiri --
--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib