在OSX 10.8.4上安装Rails失败



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

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

终于找到了解决方案!运行rvm内爆,并使用rm删除/etc/rvmrc和~/.rmvrc,重新启动mac,然后可以使用gem install rails成功安装rails。

首先,我通过自制程序安装了gcc:

使用brew 在mavericks上安装gcc

brew tap homebrew/dupesbrew install apple-gcc42

然后我符号链接了新安装的应用程序-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

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

最新更新