Marvericksでgem installしようとしてハマった

gemでv8 engineをinstallしようとしたらgcc関係のエラーが出たので調べた

以下,エラーメッセージ

$ gem install libv8 -v "3.11.8.17"
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
ERROR: Failed to build gem native extension.
    ~/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.3
Using compiler: /usr/local/bin/g++
g++: error: unrecognized command line option '-Wnewline-eof'
make[1]: *** [~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/ext/libv8/location.rb:35:in `each'
from ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/ext/libv8/location.rb:35:in `verify_installation!'
from ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
GYP_GENERATORS=make 
build/gyp/gyp --generator-output="out" build/all.gyp 
             -Ibuild/standalone.gypi --depth=. 
             -Dv8_target_arch=x64 
             -S.x64  -Dv8_can_use_vfp_instructions=true
  CXX(target) ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
 
Gem files will remain installed in ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17 for inspection.

Results logged to ~/.rvm/gems/ruby-2.0.0-p247/gems/libv8-3.11.8.17/ext/libv8/gem_make.out

調べてみると,gccXcode付属のllvm-gccじゃなくてhomebrewでinstallしたgcc49にしてたのが原因っぽい.

解決策

シンボリックリンクを削除

$ sudo rm /usr/local/bin/gcc
$ sudo rm /usr/local/bin/g++

ここからGCC-10.7.pkgをインストール

~/.bash_profileに以下を追加

export CC="/usr/bin/gcc-4.2"

うまくいきました₍˄·͈༝·͈˄₎◞ ̑̑ෆ⃛

$gem install libv8 -v "3.11.8.17"
Building native extensions.  This could take a while...
Successfully installed libv8-3.11.8.17
Parsing documentation for libv8-3.11.8.17
Installing ri documentation for libv8-3.11.8.17
Done installing documentation for libv8 after 1 seconds
1 gem installed

参考サイト

bundle install ができなくてはまったのでやった対策

MacOSX LionでのRubyの扱い方、またはllvm-gccについて。