如何在没有 Xcode 的情况下在 Mac OS X Mountain Lion 中安装 Ruby 1.9.3?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11436674/
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-06 05:17:03  来源:igfitidea点击:

How can I install Ruby 1.9.3 in Mac OS X Mountain Lion without Xcode?

rubyosx-mountain-lion

提问by David Morales

I would like to know about alternative ways to build a development machine for Ruby 1.9.3 on OS X 10.8 Mountain Lion, that does not require Xcode.

我想知道在 OS X 10.8 Mountain Lion 上为 Ruby 1.9.3 构建开发机器的替代方法,不需要 Xcode。

Mountain Lion is now Golden Master as I'm writing this question, so it could be considered as final version. That cannot be said about Xcode, that is a preview release yet.

在我写这个问题的时候,山狮现在是金大师,所以它可以被认为是最终版本。关于 Xcode 不能说,那是一个预览版本。

RVM recommends to install osx-gcc-installer over Xcode, but I would like not to mess my system.

RVM 建议通过 Xcode 安装 osx-gcc-installer,但我不想弄乱我的系统。

What is the cleanest way to install Ruby 1.9.3 on Mountain Lion without Xcode?

在没有 Xcode 的情况下在 Mountain Lion 上安装 Ruby 1.9.3 的最干净方法是什么?

回答by David Morales

osx-gcc-installer turns out to be a very good option to replace Xcode in order to install Ruby 1.9.3

osx-gcc-installer 是替换 Xcode 以安装 Ruby 1.9.3 的一个很好的选择

These are the steps I have followed:

这些是我遵循的步骤:

  1. Download & install the latest version of osx-gcc-installer here (GCC-10.7-v2 is fine): https://github.com/kennethreitz/osx-gcc-installer
  2. Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/
  3. Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
  4. Install libksba to resolve some dependencies with Ruby 1.9.3: brew install libksba
  1. 在此处下载并安装最新版本的 osx-gcc-installer(GCC-10.7-v2 很好):https: //github.com/kennethreitz/osx-gcc-installer
  2. 像往常一样安装RVM并选择1.9.3-head作为默认的ruby安装:https: //rvm.io/rvm/install/
  3. 安装 Homebrew:https: //github.com/mxcl/homebrew/wiki/installation
  4. 安装 libksba 以解决与 Ruby 1.9.3 的一些依赖关系: brew install libksba

That's it!You should now have Ruby 1.9.3 installed on Mountain Lion working perfectly.

就是这样!您现在应该在 Mountain Lion 上安装了 Ruby 1.9.3,可以完美运行。

If you need some other packages, install them now through Homebrew, such as Imagemagick for example: brew install imagemagick

如果您需要其他一些软件包,请立即通过 Homebrew 安装它们,例如 Imagemagick: brew install imagemagick

It's possible that you need XQuartz for Homebrew to work properly, as Apple is not shipping X11 since Mountain Lion. You can download it here: http://xquartz.macosforge.org/trac/wiki

您可能需要 XQuartz for Homebrew 才能正常工作,因为自 Mountain Lion 以来,Apple 不再发布 X11。你可以在这里下载:http: //xquartz.macosforge.org/trac/wiki

EDIT:

编辑:

Now (since 29th July) Command line tools for Xcode 4.4 are available.

现在(自 7 月 29 日起)Xcode 4.4 的命令行工具可用。

So, the new steps are these:

所以,新的步骤是:

  1. Download & install Command line tools for Xcode 4.4 (you don't need to download Xcode): https://developer.apple.com/downloads/index.action
  2. Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
  3. Install automake: brew install automake
  4. Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/
  1. 下载并安装 Xcode 4.4 的命令行工具(你不需要下载 Xcode):https: //developer.apple.com/downloads/index.action
  2. 安装 Homebrew:https: //github.com/mxcl/homebrew/wiki/installation
  3. 安装自动生成器: brew install automake
  4. 像往常一样安装RVM并选择1.9.3-head作为默认的ruby安装:https: //rvm.io/rvm/install/

Optional step: You may need XQuartz for some components, for example for Imagemagick, so download & install XQuartz: http://xquartz.macosforge.org/trac/wiki

可选步骤:对于某些组件,例如 Imagemagick,您可能需要 XQuartz,因此下载并安装 XQuartz:http: //xquartz.macosforge.org/trac/wiki

回答by fuzzygroup

I also had to add this:

我还必须添加这个:

export CC=/usr/bin/gcc-4.2

导出 CC=/usr/bin/gcc-4.2

in order to make the Apple command line tools work with the rvm. Without this I had repeated llvm issues:

为了使 Apple 命令行工具与 rvm 一起工作。没有这个,我重复了 llvm 问题:

The provided CC(gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

提供的 CC(gcc) 是基于 LLVM 的,ruby 和 gems 尚未完全支持它,请阅读rvm requirements

回答by mhartl

I had to add

我不得不添加

export CPPFLAGS=-I/opt/X11/include

as well as

export CC=/usr/local/bin/gcc-4.2

I was still getting compilation errors due to readline (things like readline.c: In function ‘readline_s_vi_editing_mode_p':in the make.log file), and the RVM readline pagedidn't seem to help, so I ran

由于 readline(例如readline.c: In function ‘readline_s_vi_editing_mode_p':make.log 文件中的内容),我仍然遇到编译错误,并且RVM readline 页面似乎没有帮助,所以我跑了

brew install readline

followed by

其次是

rvm install 1.9.3 -C --with-readline-dir=/usr/local/Cellar/readline/6.2.4