在 Mac OS X (Yosemite) 上安装 rails 时遇到问题

Having trouble installing rails on Mac OS X (Yosemite)

我正在尝试在我的 Mac OS X (Yosemite) 上安装 rails。 我收到以下错误:

Mohammads-iMac:~ mohammadriazi$ gem install rails --no-ri --no-rdoc
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/2.0/usr/bin/ruby
extconf.rb checking if the C compiler accepts ... yes checking if the
C compiler accepts
-Wno-error=unused-command-line-argument-hard-error-in-future... no 
Building nokogiri using packaged libraries. checking for gzdopen() in
-lz... yes checking for iconv... yes
************************************************************************ IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2 with the
following patches applied:
    - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
    - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.

我确实尝试更新 gem,但我仍然收到错误消息。 我还安装了自制软件

请帮忙! 谢谢

感谢各位指点! 我在这里读了这篇文章: https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x

它帮助我理解了 rbenv。

  • 然后我将我的 rbenv 和 Homebrew 更新到最新版本。
  • 将我的默认 ruby 版本设置为可用的最新版本。 (我猜我的 MAC OS X 上安装的系统 Ruby 是默认设置,这是导致问题的原因)
  • 最后我用gem安装了最新版本的rails然后重新hash。

现在一切正常! 谢谢