错误:安装rails时出错:错误:无法构建gem原生扩展

时间:2012-12-01 18:54:27

标签: ruby xcode macos

我在我的rails应用程序上遇到了一些json错误(它在一个相当旧的版本上),其他地方出现了一些mysql错误,所以我用rvm重新安装了最新版本的所有内容。我正在谷歌搜索的很多东西都说xcode的旧版本,但是当我运行xcodebuild -version时,我得到了:

Xcode 4.5.2
Build version 4G2008a

以下是gem install rails的完整错误:

jakes-MacBook-Pro:~ mctesterson$ sudo gem install rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.4.0.gem (100%)
Fetching: activesupport-3.2.9.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.9.gem (100%)
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.2.2.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.9.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.35.gem (100%)
Fetching: activerecord-3.2.9.gem (100%)
Fetching: activeresource-3.2.9.gem (100%)
Fetching: mime-types-1.19.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.12.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.9.gem (100%)
Fetching: rake-10.0.2.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: thor-0.16.0.gem (100%)
Fetching: json-1.7.5.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

        /Users/mctesterson/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1


Gem files will remain installed in /Users/mctesterson/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/json-1.7.5 for inspection.
Results logged to /Users/mctesterson/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out

1 个答案:

答案 0 :(得分:2)

看起来好像是在错误的地方寻找我的gcc东西。

我运行以下内容并且有效:

sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

(看过这篇文章,发现在Franco的解决方案下:error: failed to build gem native extension when installing rails on mac mountian lion os