Ruby-on-rails 在 Mavericks 上安装 Rails

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19580685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:56:13  来源:igfitidea点击:

Installing Rails on Mavericks

ruby-on-railsmacososx-mavericks

提问by john doe

Not sure what happened but when I upgraded to Mavericks it says that Rails it not install. I executed the following command:

不知道发生了什么,但是当我升级到 Mavericks 时,它说它没有安装 Rails。我执行了以下命令:

rails --version

And it said "Rails is not currently installed and run sudo gem install rails".

它说“当前未安装 Rails 并运行 sudo gem install rails”。

I run sudo gem install rails and get the following:

我运行 sudo gem install rails 并得到以下信息:

ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.

UPDATE:

更新:

I ran the command gcc --version and got the following:

我运行命令 gcc --version 并得到以下信息:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

回答by Marcelo De Polli

You need to install the Command Line Developer Tools. Just open Terminal and type up a command that requires it -- for instance, git, gccor make. Or use the following command:

您需要安装命令行开发工具。只需打开终端并输入需要它的命令 - 例如,git,gccmake。或者使用以下命令:

$ xcode-select --install

You'll see an alert like this:

你会看到这样的警报:

enter image description here

enter image description here

Just click Install and that's it. As of OS X 10.9, there's no longer need to install Xcodefor Ruby development.

只需单击“安装”即可。从 OS X 10.9 开始,不再需要为 Ruby 开发安装 Xcode

Credit for the steps and picture goes to Daniel Kehoe in his latest guide: http://railsapps.github.io/installrubyonrails-mac.html

步骤和图片归功于 Daniel Kehoe 在他的最新指南中:http: //railsapps.github.io/installrubyonrails-mac.html

回答by ifearthenight

I had the same problem which I have now been able to solve.

我有同样的问题,我现在已经能够解决。

The problem for me was that I had updated to the latest version of Xcode through the appstore but hadn't actually opened the application to complete the install. So here's what solved it for me:

我的问题是我已经通过 appstore 更新到最新版本的 Xcode,但实际上并没有打开应用程序来完成安装。所以这就是为我解决的问题:

  • Updated Xcode
  • Opened Xcode application
  • Accepted license agreement
  • Installed rails
  • 更新了 Xcode
  • 打开的 Xcode 应用程序
  • 接受的许可协议
  • 安装导轨

Hope it works for you too.

希望它也适用于你。

回答by Bernardo

It wasn't working for me even when I reinstalled xcode and the command line tools for mavericks.

即使我为小牛重新安装了 xcode 和命令行工具,它也对我不起作用。

But after that, I just did a bundle updateand, for some reason, it worked.

但在那之后,我只是做了一个,bundle update并且由于某种原因,它奏效了。

回答by Aung

I think I had the same issues. I updated the xcode and open xcode to accept licence aggrement. Then it worked fine as far as I can remember.

我想我有同样的问题。我更新了 xcode 并打开 xcode 以接受许可协议。然后它工作得很好,据我所知。