【问题标题】:Install Rails Failed on OSX 10.8.4在 OSX 10.8.4 上安装 Rails 失败
【发布时间】:2013-08-11 03:44:16
【问题描述】:

在我的新Air上安装OSX 10.8.4总是失败,即使我成功安装了ruby2,XCode的命令行工具,当我尝试安装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

【问题讨论】:

  • 您似乎安装了rvm。你使用sudo gem install而不是gem install有什么特别的原因吗?
  • mkmf.log 的内容是什么?
  • 我使用sudo gem install 因为如果我只是使用gem install,它会提示有一些权限问题。
  • 不知道mkmf.log在哪里,用whereis命令找不到,能不能给个路径?谢谢!
  • 查看这个帖子:stackoverflow.com/questions/11802918/… 它讨论了一个与你的问题非常相似的问题

标签: ruby-on-rails gem


【解决方案1】:

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

【讨论】:

  • 我必须rvm get stable,然后是rvm reinstall 2.0.0,但这对我来说很有效。谢谢。
【解决方案2】:

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

【讨论】:

  • 注意这一点 - rvm implode 会从您的系统中删除所有 rvm gemset,因此如果您已经有项目在 RVM 上运行,这将重置它们。
【解决方案3】:

首先我通过自制软件安装了 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

【讨论】:

  • 我刚刚在 El Capitan 上遇到了同样的问题。对于在 El Capitan 上遇到此问题的任何其他人,请尝试按照这些说明进行操作,但请跳过 sudo mv gcc gcc_mavs
【解决方案4】:

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

【讨论】:

    猜你喜欢
    • 2015-10-24
    • 2013-07-25
    • 2013-08-27
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多