LoginSignup
15
14

More than 5 years have passed since last update.

OS X Yosemite で Nokogiri gem を bundle install

Posted at

mac nokogiri インストール でググれば山のように出てくるけど、一応自分のやった方法も書き残しておきます。

バージョン

  • Mac OS X 10.10.2
  • Ruby 2.1.5 (by rbenv)
  • Nokogiri 1.6.3.1

bundle install する

何も考えずに bundle install したら、libiconv が無いと言われました。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/dtan4/.anyenv/envs/rbenv/versions/2.1.5/bin/ruby -r ./siteconf20150224-35319-1dn56el.rb extconf.rb
Building nokogiri using packaged libraries.
-----
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 necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

ここで brew install libiconv && brew link libiconv とか gem 単体インストールとかチャレンジしましたが、それでもインストールがコケる…つらい…

解決

Nokogiri 公式サイトに書いてある方法 でだいたいいけました。bundle install するときは bundle config のくだりを事前に実行してあげるのが大切です。

$ gem update --system
$ xcode-select --install
$ bundle config build.nokogiri --use-system-libraries
$ bundle install

REF

15
14
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
15
14