アラのアラアラしい日記

こっそりかいてます

Yosemiteにしたらbundle installが出来なくなった話

こんにちはこんにちは!!わたしあらちゃん!

先日MacOSYosemiteにしました!
そしたらbundle installが出来なくなりました!!やったー!!

やろうとしていたのはrailsの中のbundle installですが、
こんな感じのエラーが出ました。

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... *** 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.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib

~~~~(略)~~~~

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:1003:in `have_func'
        from extconf.rb:3:in `<main>'


Gem files will remain installed in /Users/USERNAME/development/APPNAME/.bundle/ruby/2.0.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Users/USERNAME/development/APPNAME/.bundle/ruby/2.0.0/gems/nio4r-1.0.0/ext/nio4r/gem_make.out
An error occurred while installing nio4r (1.0.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.0.0'` succeeds before bundling.

nio4rのインストールでエラーが出ました。
「mkmf.logを見てね」と書いてあるので見ててると、

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found

logの中の一行に上のような内容が書いてあって、
確かに対象のディレクトリからconfig.hというがファイルが消えていました。

他の方々のブログでも書いてありましたが、
解決方法としてはxcodeのcommand line toolsもバージョンアップしていたようなので、
xcodeもupdateする必要がありました。(普通にapp storeにありました)

また、brew doctorをしてみたらhomebrewも
最新版にupdateする必要があることが判りました。

Warning: Your Xcode (6.0.1) is outdated
Please update to Xcode 6.1.
Xcode can be updated from the App Store.

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

xcodeをupdateしてから再度bundle installをしてみたら、

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher

またエラーが出ました。

半ギレで見てみると「gccのバージョンを4.4以上にしてね」ということなので、 現在のgccバージョンを確認してみると、

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

4.2でした。
※今のところxcodeを入れた時のデフォが4.2のようです。
参考: UsingTheRightCompiler – MacPorts

というわけでhomebrewで最新版のgccをinstallしました。

ちなみに今回のxcodeのupdateは1時間10分程度、
gccのインストールは1時間30分程度でした。
やたら長かったんだけどこんなもんなのかな・・・

あと、このupdateで他にもgcc, g++とか、libv8, therubyracerのインストールまわりで
めちゃくそハマったので忘備録としてそのあたりについて今度書きたいと思います(白目)

おやすみなさい
_(┐「ε:) (:3」∠)_

追記: この記事の続きを書きました。