使用 Xcode 4.3.1 在 Mac 上更新 Ruby 的问题

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

Issue updating Ruby on Mac with Xcode 4.3.1

rubyxcodeosx-lionrvm

提问by xivo

I'm using RVM to install it and it gives me this error:

我正在使用 RVM 安装它,它给了我这个错误:

The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.

I'm on Lion 10.7.3 and I have Xcode 4.3.1.

我在 Lion 10.7.3 上,我有 Xcode 4.3.1。

回答by shigeya

Short answer is you can grab RVM master branch (not stable) to build it with LLVM (not gcc, I mistyped initially). It has appropriate patches to make 1.9.3-p125 to run (at least better) with Xcode 4.3.1 by default. I provided the patch. If you already installed RVM, rvm get headwill install the master branch. With command line tools installed with Xcode 4.3.1, you can successfully install Ruby 1.9.3-p125.

简短的回答是您可以获取 RVM 主分支(不稳定)以使用 LLVM(不是 gcc,我最初输入错误)来构建它。默认情况下,它有适当的补丁使 1.9.3-p125 与 Xcode 4.3.1 一起运行(至少更好)。我提供了补丁。如果你已经安装了 RVM,rvm get head将安装 master 分支。使用 Xcode 4.3.1 安装的命令行工具,您可以成功安装 Ruby 1.9.3-p125。

Background

背景

It's happen due to a simple configuration issue of Ruby 1.9.3-p125, it don't allow dynamic link modules to work. This happens if you're using Xcode 4.3.x (Ruby Issue#6080).

这是由于 Ruby 1.9.3-p125 的一个简单配置问题导致的,它不允许动态链接模块工作。如果您使用的是 Xcode 4.3.x(Ruby Issue#6080),就会发生这种情况。

This issue have fixed in change set r34840.

此问题已在更改集 r34840 中修复

RVM has patch system which provides per-version basis. This patch is included in the RVM (master branch for now) and now default for p125 configuration steps.

RVM 有补丁系统,提供每个版本的基础。此补丁包含在 RV​​M(现在是主分支)中,现在默认用于 p125 配置步骤。

Xcode 4.3.x Command Line Tool

Xcode 4.3.x 命令行工具

First, With Xcode 4.3.x, you need to install command line tool AFTER installing Xcode 4.3.x, by following directions: 1) Launching Xcode, 2) Open “Preferences” from the “Xcode” item on the menu bar. 3) Select “Downloads” tab (icon). 4) Click “Install” button for “Command Line Tools” (directions borrowed from my friend's site here)

首先,使用 Xcode 4.3.x,您需要在安装 Xcode 4.3.x 后安装命令行工具,按照以下说明:1) 启动 Xcode,2) 从菜单栏上的“Xcode”项中打开“首选项”。3) 选择“下载”选项卡(图标)。4)单击“命令行工具”的“安装”按钮(从我朋友的网站借来的说明在这里

If Xcode 4.3.1 is correctly installed, then cc --versionshould emit:

如果 Xcode 4.3.1 安装正确,则cc --version应该发出:

% cc --version
Apple clang version 3.1 (tags/Apple/clang-318.0.54) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

autoconf and automake

autoconf 和 automake

You need autoconf and automake, since Xcode 4.3.x don't have them. Install them either brewor MacPorts.With MacPorts:

您需要 autoconf 和 automake,因为 Xcode 4.3.x 没有它们。安装它们brewMacPorts.使用MacPorts

sudo port install autoconf automake

Recommended installation step with RVM

推荐的 RVM 安装步骤

Then, To install specific branch of RVM, you can:

然后,要安装 RVM 的特定分支,您可以:

REPO=wayneeseguin
BRANCH=master # stable for the stable branch
curl -s https://raw.github.com/${REPO}/rvm/${BRANCH}/binscripts/rvm-installer > /tmp/rvm-installer.sh
bash /tmp/rvm-installer.sh --branch ${REPO}/${BRANCH}

Or if RVM is already installed:

或者如果 RVM 已经安装:

rvm get head   # master branch, for stable branch "rvm get stable"

After that, install openssl, iconv and readline using rvm pkg command for best result. I do following lately. Part of this might need to be included to RVM..

之后,使用 rvm pkg 命令安装 openssl、iconv 和 readline 以获得最佳结果。我最近在关注。其中一部分可能需要包含在 RV​​M 中。

rvm pkg install openssl
rvm pkg install readline # if you prefer GNU readline

Then, finally, install the Ruby.

然后,最后,安装 Ruby。

rvm install 1.9.3-p125 --patch xcode-debugopt-fix-r34840.diff --with-readline-dir=$rvm_path/usr --with-openssl-dir=$rvm_path/usr --with-tcl-lib=/usr --with-tk-lib=/usr

rvm pkg's help recommend different parameter, the help is broken. So use above for now. You need tcl/tk parameters if you have them via MacPorts(like me)

rvm pkg 的帮助推荐了不同的参数,帮助坏了。所以现在使用上面的。如果您通过 MacPorts 获得 tcl/tk 参数,则需要它们(像我一样)

By the way, It is possible to install old Xcode then run rvm with export CC="gcc-4.2" rvm install 1.9.3-p125, but I personally think clang (LLVM) is the way to go for future, if possible.

顺便说一下,可以安装旧的 Xcode 然后使用 rvm 运行 rvm export CC="gcc-4.2" rvm install 1.9.3-p125,但我个人认为,如果可能的话,clang (LLVM) 是未来的发展方向。

Hope this helps.

希望这可以帮助。

Additional note on 2012/3/31

2012/3/31 补充说明

iconv don't need to install, also added autoconf/automake requirements for clarifications.

iconv 不需要安装,还添加了 autoconf/automake 要求以进行说明。

Additional note on 2012/4/13

2012/4/13 补充说明

Latest stable does not include the patch require dynamic link to work by default. you need to add --patch xcode-debugopt-fix-r34840.diffwhen you build 1.9.3-p125.

最新稳定版不包括补丁需要动态链接才能默认工作。--patch xcode-debugopt-fix-r34840.diff构建1.9.3-p125时需要添加。

回答by docwhat

As of RVM 1.10.2 all you need is to install the homebrewpackage apple-gcc42and everything will "Just Work(TM)":

从 RVM 1.10.2 开始,您只需要安装homebrewapple-gcc42,一切都会“Just Work(TM)”:

brew tap homebrew/dupes ; brew install apple-gcc42 ; rvm install ruby-1.9.2

brew tap homebrew/dupes ; brew install apple-gcc42 ; rvm install ruby-1.9.2

Ciao!

再见!

[Updated based on comments below]

[根据以下评论更新]

回答by big-circle

You just need to install gcc-4.2 in /usr/bin.

您只需要在 /usr/bin 中安装 gcc-4.2。

Here is the download https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg.

这是下载https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg

And then CC=/usr/bin/gcc-4.2 rvm install 1.8.7 --force

然后 CC=/usr/bin/gcc-4.2 rvm install 1.8.7 --force

回答by jensab

I think people are confused that everyone writes

我认为人们很困惑,每个人都在写

rvm get head
rvm get stable

instead you should ONLY write

相反,你应该只写

rvm get head

otherwise it will not work (since stable does not have the corresponding patches yet).

否则它将无法工作(因为稳定版还没有相应的补丁)。

回答by Francois

I also had an issue with ruby-1.9.3-p125, here is what I did, hope this can help someone down the line.

我也遇到了 ruby​​-1.9.3-p125 的问题,这就是我所做的,希望这可以帮助某人。

rvm install ruby-1.9.3-p194

rvm 安装 ruby​​-1.9.3-p194

and checked that the new ruby installed with

并检查新的 ruby​​ 是否安装了

rvm list

房车清单

ruby-1.9.2-p318 [ x86_64 ]
ruby-1.9.3-p125 [ x86_64 ] I want to remove this one
ruby-1.9.3-p194 [ x86_64 ] I want to use this one

I then removed the old ruby version

然后我删除了旧的 ruby​​ 版本

rvm remove ruby-1.9.3-p125

rvm 删除 ruby​​-1.9.3-p125

and set the new one ruby ruby-1.9.3-p194 for use and install gems

并设置新的 ruby​​ ruby​​-1.9.3-p194 以供使用并安装 gems

rvm use ruby-1.9.3-p194

bundle install

rvm 使用 ruby​​-1.9.3-p194

捆绑安装

回答by Dale

I have installed and tested with the following similar to suggestions above. However I just uninstalled everything and did the basic install for all of these. The only exception was that instead of using the xcode preference dialog to install the command line tools (which failed for me). Apple posted a stand alone which I used in item 2.)

我已经安装并测试了以下类似于上面的建议。但是,我只是卸载了所有内容并为所有这些进行了基本安装。唯一的例外是没有使用 xcode 首选项对话框来安装命令行工具(这对我来说失败了)。Apple 发布了一个我在第 2 项中使用的独立版本。)

  1. Download and install xCode 4.3.2
  2. Download and Install Command line Tools for Xcode late March 2012
  3. Set xcode path $ xcode-select -switch /Application/xcode.app/Content/Developer
  4. Install Homebrew and then install git, autoconf, automake, libyaml, libksba, wget via Brew.
  5. Install RVM make sure it is setup in you shell
  6. rvm install ruby-1.9.3-p125
  1. 下载并安装 xCode 4.3.2
  2. 2012 年 3 月下旬下载并安装适用于 Xcode 的命令行工具
  3. 设置 xcode 路径 $ xcode-select -switch /Application/xcode.app/Content/Developer
  4. 安装 Homebrew,然后通过 Brew 安装 git、autoconf、automake、libyaml、libksba、wget。
  5. 安装 RVM 确保它在你的 shell 中设置
  6. rvm 安装 ruby​​-1.9.3-p125

There are articles out there recommending this for ruby >=1.9.3 and thats all I have tested and currently use. I did install and use mysql2, sqlite, and the usual suspect (GEMs) They all compiled and passed some of my basic tests

有文章推荐 ruby​​ >=1.9.3 这就是我测试和当前使用的所有内容。我确实安装并使用了 mysql2、sqlite 和通常的嫌疑犯 (GEM) 他们都编译并通过了我的一些基本测试

Hope this helps.

希望这可以帮助。