■【Mac】【RubyGems】/usr/bin/gcc-4.2 がない!
$ gem update
としたところ、以下のエラーで怒られました。
Updating installed gems
Updating bcrypt-ruby
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
/Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/bin/ruby extconf.rb
creating Makefile
make
compiling bcrypt_ext.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [bcrypt_ext.o] Error 1
Gem files will remain installed in /Users/shiori/.rvm/gems/ruby-1.9.3-preview1/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/shiori/.rvm/gems/ruby-1.9.3-preview1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
Updating rdoc
Building native extensions. This could take a while...
ERROR: Error installing rdoc:
ERROR: Failed to build gem native extension.
/Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/bin/ruby extconf.rb
checking for re.h... *** 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
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/bin/ruby
/Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:505:in `try_cpp'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:930:in `block in have_header'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:789:in `block in checking_for'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:788:in `checking_for'
from /Users/shiori/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/mkmf.rb:929:in `have_header'
from extconf.rb:14:in `
Gem files will remain installed in /Users/shiori/.rvm/gems/ruby-1.9.3-preview1/gems/json-1.6.1 for inspection.
Results logged to /Users/shiori/.rvm/gems/ruby-1.9.3-preview1/gems/json-1.6.1/ext/json/ext/parser/gem_make.out
Nothing to update
/usr/bin/gcc-4.2 がないため、make が失敗したみたい。
色々と調べてみると、LionにしてXcode4を入れると自動的に入ってます。という記事が・・・。
$ ls /usr/bin/
-
-
-
- 略 ----
- 略 ----
-
-
gcc@ gcov@ gcov-4.2@
-
-
-
- 略 ----
-
-
ふっ。ないな
もしかして、gccのバージョンって・・・
$ gcc -v
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
gcc のバージョン4.2系だね。上書きされてる??
・・・そういえばLionはアップグレードで入れたので、それが原因なのでしょうか?
gem で gcc のパスを変更する方法がよくわからないので・・・
シンボリックリンクを作ってみました。
$ sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
とりあえず、上手くできた。
応急処置なので他に良い方法がある人は是非とも教えてください。