2

我只是在我的 Mac 中将我的操作系统更新为小牛。在更新我的操作系统之前,我在 Rails 中创建一个新项目没有问题,但是现在,当我尝试创建一个新项目时出现错误。这就是我所做的:

tomers-MacBook-Pro:bootstrapProject tomerdoar$ rails new blog

我得到这个错误:

Installing json (1.8.1) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/tomerdoar/.rvm/rubies/ruby-1.9.3-p194/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/tomerdoar/.rvm/gems/ruby-1.9.3-p194/gems/json-1.8.1       for inspection.
Results logged to /Users/tomerdoar/.rvm/gems/ruby-1.9.3-p194/gems/json- 1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.

然后,正如它所说,我正在尝试安装 json -v '1.8.1'。我这样做:

tomers-MacBook-Pro:bootstrapProject tomerdoar$ gem install json -v '1.8.1'

我得到这个错误:

Building native extensions.  This could take a while...
ERROR:  Error installing json:
ERROR: Failed to build gem native extension.

    /Users/tomerdoar/.rvm/rubies/ruby-1.9.3-p194/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/tomerdoar/.rvm/gems/ruby-1.9.3-p194/gems/json-1.8.1     for inspection.
Results logged to /Users/tomerdoar/.rvm/gems/ruby-1.9.3-p194/gems/json-    1.8.1/ext/json/ext/generator/gem_make.out

从那时起,我真的不知道该怎么办。我试图在网上寻找类似的错误和解决方案,但没有任何帮助,我仍然收到此错误。

有没有办法解决它,如果有,你能告诉我一步一步怎么做吗?

4

1 回答 1

1

我自己找到了答案,我必须执行以下步骤:

tomers-MacBook-Pro:bootstrapProject tomerdoar$brew tap homebrew/versions && brew install apple-gcc42

tomers-MacBook-Pro:bootstrapProject tomerdoar$brew link --force apple-gcc42

tomers-MacBook-Pro:bootstrapProject tomerdoar$ln -nsf $(which gcc-4.2) /usr/bin/gcc-4.2

我现在没有任何问题

于 2013-11-14T05:43:45.440 回答