0

我尝试了不同的方法来安装导轨,但从来没有得到它..每次我输入“gem install rails”..它告诉我"ERROR: Failed to build gem native extension."

miketeki-iphone:~ Simon$ gem install rails
Failed to load /Users/Simon/.gemrc because it doesn't contain valid YAML hash
Fetching: i18n-0.6.5.gem (100%)
Successfully installed i18n-0.6.5
Fetching: multi_json-1.7.9.gem (100%)
Successfully installed multi_json-1.7.9
Fetching: tzinfo-0.3.37.gem (100%)
Successfully installed tzinfo-0.3.37
Fetching: minitest-4.7.5.gem (100%)
Successfully installed minitest-4.7.5
Fetching: atomic-1.1.13.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /Users/Simon/.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/Simon/.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/Simon/.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/Simon/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
    from /Users/Simon/.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/Simon/.rvm/gems/ruby-2.0.0-p247@global/gems/atomic-1.1.13 for inspection.
Results logged to /Users/Simon/.rvm/gems/ruby-2.0.0-p247@global/gems/atomic-1.1.13/ext/gem_make.out

提前致谢。

4

1 回答 1

0

从苹果开发者下载页面下载并安装“命令行工具”:https ://developer.apple.com/downloads/或者只是通过 App Store 安装 xcode .. 再试一次。

正如评论中其他人所提到的,rbenv 是在 Mac OS X 上管理 rubies 的更好、更简单的方法,因此请考虑进行切换。要从系统中删除 rvm,请执行以下操作:rvm implode然后重新启动 shell 以确保在干净的环境中安装 rbenv。

有关如何在 mac 上安装体面的 rails 开发环境的详细说明,请查看我在博客文章中汇总的说明:

http://blog.parsalabs.com/blog/2013/08/27/setting-up-a-ruby-on-rails-4-development-environment-on-a-clean-mac-os-x-installation/

它们为我工作,希望你也会发现它们也有用。

于 2013-09-04T06:12:10.770 回答