1

我正在尝试从新创建的 Rails 应用程序更新 gem 文件。每次我得到以下信息:

Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.0)
Using bundler (1.3.5)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.2)
Using jquery-rails (3.0.4)
Installing json (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/adrianleeelder/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
creating Makefile

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


Gem files will remain installed in /Users/adrianleeelder/.rvm/gems/ruby-2.0.0-p0/gems/json-1.8.1 for inspection.
Results logged to /Users/adrianleeelder/.rvm/gems/ruby-2.0.0-p0/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.

不久前我更新到 OS X Mavericks,自从我遇到了这个问题。很多用户建议运行命令:xcode-select --install。

4

2 回答 2

8

我通过执行以下操作修复了错误:

1)运行命令which gcc

2)然后根据输出调整此命令并运行它:(ln -s /usr/bin/gcc /usr/bin/gcc-4.2如果权限被拒绝,可能必须预先添加 sudo)

bundle 命令现在应该可以正确编译 gem。

安装 Xcode 也可以。我已经安装了 Xcode,但由于某种原因,当我最近尝试启动它时,它提示安装。使用 Alfred(快速启动应用程序)我键入 Xcode 并启动安装程序。

于 2013-11-03T17:53:26.907 回答
0

我使用以下方法通过自制软件修复了错误:

brew tap homebrew/versions && brew install apple-gcc42

brew link --force apple-gcc42

ln -nsf $(which gcc-4.2) /usr/bin/gcc-4.2

'sudo'如果您遇到权限问题,您可能必须执行最后一个命令。

于 2014-02-09T23:00:20.177 回答