0

我正在尝试使用以下教程:http ://ruby.railstutorial.org/ruby-on-rails-tutorial-book?version=3.2#sec-install_ruby

当我这样做时,sudo gem install rails -v 3.2.9我收到此错误:

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

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb creating Makefile

make xcrun cc -I.
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0
-I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0
-I. -DJSON_GENERATOR  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c generator.c xcrun: Error: failed to exec real xcrun. (No such file or directory) cc -arch i386 -arch
x86_64 -pipe -bundle -undefined dynamic_lookup -o generator.bundle
generator.o -L.
-L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64     -lruby  -lpthread -ldl -lobjc   clang: error: no such file or directory: 'generator.o' make: ***
[generator.bundle] Error 1

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.5/ext/json/ext/generator/gem_make.out

我已经安装了命令行工具

我已经设置了 sudo xcode-select -switch /usr/bin

哪个 xcode-select /usr/bin/xcode-select

哪个抄送/usr/bin/cc

有任何想法吗?谢谢!

4

2 回答 2

0

您需要安装完整的 XCode 应用程序才能使用系统 Ruby 为 gems 构建 C 扩展。

如果您不想安装 XCode,另一种选择是使用rvmruby-buildruby ​​-install 编译您自己的 Ruby 。

于 2013-08-15T01:14:19.747 回答
0

如果有人使用 Xcode 5:

  1. 从 Xcode 的设置菜单安装命令行
  2. 使用“mac 端口”安装 ruby​​ 1.8.7
  3. 重试“gem install cocopods”

这解决了我的相同问题。

于 2013-10-04T19:52:39.843 回答