1

我总是在我的新 Air 上用 OSX 10.8.4 安装 rails 失败,即使我成功安装了 XCode 的命令行工具 ruby​​2,当我尝试安装 rails 时它仍然提示一些错误。

我从互联网上找到了很多解决方案,但它们都不适用于我的问题,我完全困惑,没有任何可以帮助我吗?我真的很感激!!!


    localhost:myapp zerocool$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
localhost:myapp zerocool$ sudo gem install rails
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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/zerocool/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
    --with-atomic_reference-dir
    --without-atomic_reference-dir
    --with-atomic_reference-include
    --without-atomic_reference-include=${atomic_reference-dir}/include
    --with-atomic_reference-lib
    --without-atomic_reference-lib=${atomic_reference-dir}/
/Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
    from /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
    from extconf.rb:24:in `<main>'


Gem files will remain installed in /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out
4

4 回答 4

2

我今天遇到了这个问题,我下载的 ruby​​-2.0.0 似乎没有正常工作。我建议尝试rvm reinstall 2.0.0后跟gem install rails.

于 2013-10-31T15:37:13.633 回答
1

首先我通过自制软件安装了 gcc:

使用 brew 在小牛上安装 gcc

brew tap homebrew/dupes brew install apple-gcc42

然后我将新安装的 apple-gcc42 符号链接到我的 /usr/bin 文件夹中

cd /usr/bin

sudo mv gcc gcc_mavs sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc

学分:https ://coderwall.com/p/lqpp8w

于 2014-02-05T05:52:22.743 回答
1

最后,我得到了解决方案!运行rvm implode,使用rm删除 /etc/rvmrc 和 ~/.rmvrc ,重启你的mac,就可以使用gem install rails 成功安装rails了。

于 2013-08-11T14:42:29.870 回答
0

在针对 ruby​​-2.0.0-p195 运行时,我遇到了同样的错误,但更新到 ruby​​-2.0.0-p247(当前 RVM 默认为 2.0.0)修复了它。

于 2013-12-18T03:43:30.320 回答