bundle installでgemをインストールする際に以下のエラーが発生しました。ちなみにインストールしようとしたgemはcapybara-webkit (1.1.1)です。
$ bundle install
Fetching source index from https://rubygems.org/
Using rake (10.1.0)
…
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Command 'qmake -spec macx-g++ ' not available
Gem files will remain installed in /Users/nishizakijuntakashi/workspace/sherpa.ag/vendor/bundle/ruby/2.0.0/gems/capybara-webkit-1.1.1 for inspection.
Results logged to /Users/nishizakijuntakashi/workspace/sherpa.ag/vendor/bundle/ruby/2.0.0/gems/capybara-webkit-1.1.1/./gem_make.out
An error occurred while installing capybara-webkit (1.1.1), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v '1.1.1'` succeeds before bundling.
どうやらcapybara-webkit (1.1.1)のインストール時にExtensionBuildErrorが発生しているようです。capybara-webkit (1.1.1)がgem installできるのか試してみます。
$ gem install capybara-webkit -v '1.1.1'
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Command 'qmake -spec macx-g++ ' not available
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/capybara-webkit-1.1.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/capybara-webkit-1.1.1/./gem_make.out
やはりBuildエラーのようで通りません…。色々探してみて
こちらの記事に行き着きました。記事を読んでみると、brew updateからのqtをインストールすれば通るとあります。試してみます。
$ brew update
Updated Homebrew from e126ec92 to 95bedd4d.
==> New Formulae
…
==> Deleted Formulae
colormake erviz flume flume-ng libusbx scalate scrotwm
次にqtをインストールします。
$ brew install qt
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.5.mavericks.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring qt-4.8.5.mavericks.bottle.4.tar.gz
==> Caveats
We agreed to the Qt opensource license for you.
If this is unacceptable you should uninstall.
.app bundles were installed.
Run `brew linkapps` to symlink these to /Applications.
==> Summary
🍺 /usr/local/Cellar/qt/4.8.5: 2780 files, 120M
インストールが完了したので、再度bundle installしてみます。
$ bundle install
Fetching source index from https://rubygems.org/
Using rake (10.1.0)
…
Installing capybara-webkit (1.1.1)
Your bundle is complete!
It was installed into ./vendor/bundle
成功しました!問題なくcapybara-webkit (1.1.1)がインストールされました。
まとめ
$ bundle install
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
↓
↓
↓
$ bundle install
以上でエラーを解決することができます。