无法使用 RVM 在 Lion 下安装 Ruby – GCC 问题

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

Can't install Ruby under Lion with RVM – GCC issues

rubygccrvmosx-lionxcode4.2

提问by Jamie Schembri

Most questions regarding this problem are due to missing Xcode; I have Xcode 4.2 installed.

大多数关于这个问题的问题是由于缺少 Xcode;我安装了 Xcode 4.2。

Install attempt:

安装尝试:

rvm install 1.9.3
Installing Ruby from source to: /Users/jamie/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...

ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #extracted to /Users/jamie/.rvm/src/ruby-1.9.3-p0 (already extracted)
Fetching yaml-0.1.4.tar.gz to /Users/jamie/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/jamie/.rvm/src
Configuring yaml in /Users/jamie/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/jamie/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/jamie/.rvm/usr
ruby-1.9.3-p0 - #configuring 
ERROR: Error running ' ./configure --prefix=/Users/jamie/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/jamie/.rvm/usr ', please read /Users/jamie/.rvm/log/ruby-1.9.3-p0/configure.log
ERROR: There has been an error while running configure. Halting the installation.

configure.log:

配置日志:

[2011-11-07 04:32:17]  ./configure --prefix=/Users/jamie/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/jamie/.rvm/usr 
configure: WARNING: unrecognized options: --with-libyaml-dir
checking build system type... x86_64-apple-darwin11.2.0
checking host system type... x86_64-apple-darwin11.2.0
checking target system type... x86_64-apple-darwin11.2.0
checking whether the C compiler works... no
configure: error: in `/Users/jamie/.rvm/src/ruby-1.9.3-p0':
configure: error: C compiler cannot create executables
See `config.log' for more details

GCC is available:

GCC 可用:

gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

ls /usr/bin | grep gcc         
gcc
i686-apple-darwin11-llvm-gcc-4.2
llvm-gcc
llvm-gcc-4.2

Based on config.log (posted at bottom due to size) I tried symlinking gcc-4.2 to gcc and then installing:

基于 config.log(由于大小而在底部发布)我尝试将 gcc-4.2 符号链接到 gcc,然后安装:

rvm install 1.9.3                       
ERROR: The autodetected CC(/usr/bin/gcc-4.2) is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`, and set CC=/path/to/gcc .

So I could probably just grab gcc elsewhere, but I'm mostly concerned as to why this is happening. Shouldn't installing Xcode be enough?

所以我可能只是在别处抓住 gcc,但我最关心的是为什么会发生这种情况。安装 Xcode 还不够吗?

config.log:

配置日志:

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.68.  Invocation command line was

  $ ./configure --prefix=/Users/jamie/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/jamie/.rvm/usr

## --------- ##
## Platform. ##
## --------- ##

hostname = Wilson.local
uname -m = x86_64
uname -r = 11.2.0
uname -s = Darwin
uname -v = Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64

/usr/bin/uname -p = i386
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = Mach kernel version:
     Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64
Kernel configured for up to 4 processors.
4 processors are physically available.
4 processors are logically available.
Processor type: i486 (Intel 80486)
Processors active: 0 1 2 3
Primary memory available: 8.00 gigabytes
Default processor set: 110 tasks, 546 threads, 4 processors
Load average: 1.28, Mach factor: 2.71
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /Users/jamie/.rvm/usr/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /usr/local/bin
PATH: /usr/X11/bin
PATH: /Users/jamie/bin
PATH: /Users/jamie/.rvm/bin
PATH: /Users/jamie/.rvm/bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2764: checking build system type
configure:2778: result: x86_64-apple-darwin11.2.0
configure:2849: checking host system type
configure:2862: result: x86_64-apple-darwin11.2.0
configure:2882: checking target system type
configure:2895: result: x86_64-apple-darwin11.2.0
configure:3376: checking for C compiler version
configure:3385: gcc-4.2 --version >&5
./configure: line 3387: gcc-4.2: command not found
configure:3396: $? = 127
configure:3385: gcc-4.2 -v >&5
./configure: line 3387: gcc-4.2: command not found
configure:3396: $? = 127
configure:3385: gcc-4.2 -V >&5
./configure: line 3387: gcc-4.2: command not found
configure:3396: $? = 127
configure:3385: gcc-4.2 -qversion >&5
./configure: line 3387: gcc-4.2: command not found
configure:3396: $? = 127
configure:3416: checking whether the C compiler works
configure:3438: gcc-4.2    conftest.c  >&5
./configure: line 3440: gcc-4.2: command not found
configure:3442: $? = 127
configure:3480: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define CANONICALIZATION_FOR_MATHN 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3485: error: in `/Users/jamie/.rvm/src/ruby-1.9.3-p0':
configure:3487: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-apple-darwin11.2.0
ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CXXFLAGS_set=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-apple-darwin11.2.0
ac_cv_prog_CC=gcc-4.2
ac_cv_target=x86_64-apple-darwin11.2.0

## ----------------- ##
## Output variables. ##
## ----------------- ##

ALLOCA=''
AR=''
ARCHFILE=''
ARCH_FLAG=''
AS=''
ASFLAGS=''
BASERUBY='ruby'
BUILTIN_ENCOBJS=''
BUILTIN_TRANSOBJS=''
BUILTIN_TRANSSRCS=''
CAPITARGET=''
CC='gcc-4.2'
CCDLFLAGS=''
CFLAGS=''
CHDIR=''
COMMON_HEADERS=''
COMMON_LIBS=''
COMMON_MACROS=''
COUTFLAG=''
CP=''
CPP=''
CPPFLAGS=''
CPPOUTFILE=''
CXX='g++-4.2'
CXXFLAGS=''
DEFS=''
DLDFLAGS=''
DLDLIBS=''
DLEXT2=''
DLEXT=''
DLLWRAP=''
DOT=''
DOXYGEN=''
ECHO_C='\c'
ECHO_N=''
ECHO_T=''
EGREP=''
ENABLE_SHARED=''
EXECUTABLE_EXTS=''
EXEEXT=''
EXPORT_PREFIX=''
EXTOUT=''
EXTSTATIC=''
GCC=''
GNU_LD=''
GREP=''
INSTALLDOC=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
LDFLAGS=''
LDSHARED=''
LDSHAREDXX=''
LIBEXT=''
LIBOBJS=''
LIBPATHENV=''
LIBPATHFLAG=''
LIBRUBY=''
LIBRUBYARG=''
LIBRUBYARG_SHARED=''
LIBRUBYARG_STATIC=''
LIBRUBY_A=''
LIBRUBY_ALIASES=''
LIBRUBY_DLDFLAGS=''
LIBRUBY_LDSHARED=''
LIBRUBY_RELATIVE=''
LIBRUBY_SO=''
LIBS=''
LINK_SO=''
LN_S=''
LTLIBOBJS=''
MAINLIBS=''
MAJOR='1'
MAKEDIRS=''
MAKEFILES=''
MANTYPE=''
MINIOBJS=''
MINIRUBY=''
MINOR='9'
MKDIR_P=''
NM=''
NROFF=''
NULLCMD=''
OBJCOPY=''
OBJDUMP=''
OBJEXT=''
OUTFLAG=''
PACKAGE=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
PKG_CONFIG=''
PREP=''
RANLIB=''
RDOCTARGET=''
RI_BASE_NAME=''
RM=''
RMALL=''
RMDIR=''
RMDIRS=''
RPATHFLAG=''
RUBYW_BASE_NAME='rubyw'
RUBYW_INSTALL_NAME=''
RUBY_BASE_NAME='ruby'
RUBY_INSTALL_NAME=''
RUBY_PROGRAM_VERSION='1.9.3'
RUBY_RELEASE_DATE='2011-10-30'
RUBY_SO_NAME=''
RUNRUBY=''
SET_MAKE=''
SHELL='/bin/sh'
SOLIBS=''
STATIC=''
STRIP=''
SYMBOL_PREFIX=''
TEENY='1'
TEST_RUNNABLE=''
THREAD_MODEL=''
TRY_LINK=''
UNIVERSAL_ARCHNAMES=''
UNIVERSAL_INTS=''
USE_RUBYGEMS=''
WERRORFLAG=''
WINDRES=''
XCFLAGS=''
XLDFLAGS=''
XRUBY=''
XRUBY_LIBDIR=''
XRUBY_RUBYHDRDIR=''
XRUBY_RUBYLIBDIR=''
ac_ct_CC=''
ac_ct_CXX=''
ac_ct_OBJCOPY=''
ac_ct_OBJDUMP=''
arch=''
bindir='${exec_prefix}/bin'
build='x86_64-apple-darwin11.2.0'
build_alias=''
build_cpu='x86_64'
build_os='darwin11.2.0'
build_vendor='apple'
cflags=' ${optflags} ${debugflags} ${warnflags}'
configure_args=''
cppflags=''
cxxflags=' ${optflags} ${debugflags} ${warnflags}'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
debugflags=''
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
exec=''
exec_prefix='NONE'
host='x86_64-apple-darwin11.2.0'
host_alias=''
host_cpu='x86_64'
host_os='darwin11.2.0'
host_vendor='apple'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
optflags=''
pdfdir='${docdir}'
prefix='/Users/jamie/.rvm/rubies/ruby-1.9.3-p0'
program_transform_name='s&^&&'
psdir='${docdir}'
ridir=''
ruby_pc=''
ruby_version=''
rubyhdrdir=''
rubylibprefix=''
rubyw_install_name=''
sbindir='${exec_prefix}/sbin'
setup=''
sharedstatedir='${prefix}/com'
sitearch=''
sitedir=''
sitehdrdir=''
sysconfdir='${prefix}/etc'
target='x86_64-apple-darwin11.2.0'
target_alias=''
target_cpu='x86_64'
target_os='darwin11.2.0'
target_vendor='apple'
try_header=''
vendordir=''
vendorhdrdir=''
warnflags=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define CANONICALIZATION_FOR_MATHN 1

configure: exit 77

回答by Arkku

This answer was edited multiple times and now contains several alternativesolutions. Try the simple “Edit 3” solution first.

此答案已多次编辑,现在包含几种替代解决方案。首先尝试简单的“Edit 3”解决方案。

Ruby 1.9.3-p125 and later have official support for clang, so if you are installing such a version you should not need GCC. If you're installing an older version of Ruby, read on.

Ruby 1.9.3-p125 及更高版本官方支持 clang,因此如果您安装这样的版本,则不需要 GCC。如果您正在安装旧版本的 Ruby,请继续阅读。

To compile Ruby with GCC, you need a non-LLVM version of GCC, which is no longer included with XCode 4.2. Install it yourself (or downgrade to XCode 4.1 temporarily), then do CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3 --enable-shared(substituting the path to your non-LLVM gcc).

要使用 GCC 编译 Ruby,您需要非 LLVM 版本的 GCC,该版本不再包含在 XCode 4.2 中。自己安装(或暂时降级到 XCode 4.1),然后执行CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3 --enable-shared(替换非 LLVM gcc 的路径)。

Edit: https://github.com/kennethreitz/osx-gcc-installer/downloadsmay help for installing GCC. There is also some info available by running rvm requirements.

编辑:https: //github.com/kennethreitz/osx-gcc-installer/downloads可能有助于安装 GCC。还可以通过运行获得一些信息rvm requirements

Edit 2: For an easier solution, you can try adding --with-gcc=clangto the arguments to configurefor Ruby to use clang instead of GCC.

编辑 2:为了更简单的解决方案,您可以尝试添加--with-gcc=clangconfigureRuby的参数以使用 clang 而不是 GCC。

Edit 3: rvm install 1.9.3 --with-gcc=clangdoes that for you.

编辑 3rvm install 1.9.3 --with-gcc=clang为你做这件事。

Note: With current versions of XCode you need to install the command-line tools separately from the XCode menu -> Preferences -> Downloads -> Components. This is a pre-requisite for doing any compiling with XCode on the command-line, not just Ruby.

注意:对于当前版本的 XCode,您需要从 XCode 菜单 -> 首选项 -> 下载 -> 组件单独安装命令行工具。这是在命令行上使用 XCode 进行任何编译的先决条件,而不仅仅是 Ruby。

Note 2: If something doesn't work after following the steps, try doing a reboot or re-login to ensure that the environment gets set correctly.

注意 2:如果按照步骤操作后仍然无法正常工作,请尝试重新启动或重新登录以确保环境设置正确。

Note 3: Ruby versions prior to 1.9.3-p125 may not always be fully compatible with clang, so test your software thoroughly if using the “edit 3” solution in a production environment.

注意 3:1.9.3-p125 之前的 Ruby 版本可能并不总是与 clang 完全兼容,因此如果在生产环境中使用“edit 3”解决方案,请彻底测试您的软件。

回答by brian.clear

SUMMARY FOR STACK OVERFLOW

堆栈溢出的总结

I was trying to install SiriProxy on a clean Lion installation on Xcode from App Store

我试图从 App Store 在 Xcode 上的干净 Lion 安装上安装 SiriProxy

I kept getting errors like : The provided CC(/usr/bin/gcc) is LLVM based.

我不断收到错误,例如:提供的 CC(/usr/bin/gcc) 是基于 LLVM 的。

bash-3.2$ rvm install 1.9.3
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.


After 2 days finally got it working with these two lines:


2天后终于让它与这两行一起工作:

http://stackoverflow.com/questions/8000145/ruby-rvm-llvm-and-mysql

bash-3.2$ rvm get head
bash-3.2$ CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

Before that I had tried every stackoverflow article on Ruby and Lion so doing these may have done some setup that helped the above 2 steps work:

在此之前,我已经尝试了所有关于 Ruby 和 Lion 的 stackoverflow 文章,所以这样做可能已经完成了一些有助于上述 2 个步骤工作的设置:

Things I tried included:

我尝试过的事情包括:

Running Install Xcode.app (I had downloaded from App Store - running this does futher installation)

运行安装 Xcode.app(我已经从 App Store 下载了 - 运行这个会进一步安装)

Installing

安装

https://github.com/kennethreitz/osx-gcc-installer/downloads may help for installing GCC.

Set up CC in

设置 CC

more /Users//.bash_profile

更多/用户//.bash_profile

bash-3.2$ more /Users/<USERNAME>/.bash_profile 
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export CC=/usr/share/TargetConfigs/bin/gcc

First line came from SiriProxy install instruction https://github.com/plamoni/SiriProxy

第一行来自 SiriProxy 安装说明 https://github.com/plamoni/SiriProxy

2nd line export CC never seemed to work. So dont add.

2nd line export CC 似乎从来没有工作过。所以不加。

It had many versions each pointing I finally used CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

它有很多版本,每个指向我最终使用 CC=/usr/bin/gcc-4.2 rvm install 1.9.3 --enable-shared

回答by Michael Neale

rvm install 1.9.3 --with-gcc=clang

Worked for me. This was on a brand new Lion with Xcode (had no "traditional" GCC).

对我来说有效。这是在带有 Xcode 的全新 Lion 上(没有“传统”GCC)。

回答by Leif

OK I didn't have to install gcc-4.2 separately, I used the one delivered in XCode, but I had an issue where the --with-gcc=clangwasn't getting passed through. Added the following line to my .rvmrc:

好的,我不必单独安装 gcc-4.2,我使用了 XCode 中提供的那个,但是我遇到了一个--with-gcc=clang没有通过的问题。将以下行添加到我的.rvmrc

export rvm_configure_flags="--with-gcc=clang"

Worked as required

按要求工作

rvm upgrade ruby-1.9.2-p290 ruby-1.9.3-p125
...
ruby-1.9.3-p125 - #extracted to /Users/leif/.rvm/src/ruby-1.9.3-p125 (already extracted)
ruby-1.9.3-p125 - #configuring
ruby-1.9.3-p125 - #compiling 
ruby-1.9.3-p125 - #installing
....
Successfully migrated ruby-1.9.2-p290 to ruby-1.9.3-p125
Upgrade complete!

bang:$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]

Note my env is the following

注意我的环境如下

OS

操作系统

Darwin bang.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64

XCode

代码

XCode 4.2.1 Build 4D502

GCC

海湾合作委员会

i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

lrwxr-xr-x  1 root  wheel  12 22 Dec 21:30 /usr/bin/gcc -> llvm-gcc-4.2

I tried using the answer of passing --with-gcc=clangon the command line to the rvm upgrade command, but it didn't work, it didn't appear to get pass from rvm to configure. Apparently the problem in RVM of arguments not being passed to configure is fixed (in commit 1641ceb0in 2011), but even after upgrading RVM to latest (via rvm get latest) it still didn't get passed. Using the .rvmrcfile was the only way it would work for me.

我尝试使用将--with-gcc=clang命令行传递给 rvm upgrade 命令的答案 ,但是没有用,它似乎没有从 rvm 传递到配置。显然,RVM 中未传递给 configure 的参数问题已修复(在1641ceb02011年提交),但即使将 RVM 升级到最新版本(通过rvm get latest),它仍然没有通过。使用该.rvmrc文件是它对我有用的唯一方法。

回答by Chris

You can try to install Command Line Tools for Xcode, it includes GCC, LLMV and other tools that excluded in Xcode 4.2 and higher.

您可以尝试为 Xcode安装命令行工具,它包括 GCC、LLMV 和 Xcode 4.2 及更高版本中排除的其他工具。

回答by tyoc213

I will suggest brewfrom rvm requirementsI have installed it while I have already installed latest Xcode Version 4.4 (4F250)

当我已经安装了最新的 Xcode 版本 4.4 (4F250) 时,我会建议从我安装它的brewrvm requirements

Homebrew:

If you are using Homebrew, you can install the apple-gcc42 and required libraries from homebrew/dupes:

  brew update
  brew tap homebrew/dupes
  brew install autoconf automake apple-gcc42
  rvm pkg install openssl

This can live side by side with an existing Xcode 4.2+ install or Command Line Tools for Xcode.

家酿:

如果你使用 Homebrew,你可以从 homebrew/dupes 安装 apple-gcc42 和所需的库:

  brew update
  brew tap homebrew/dupes
  brew install autoconf automake apple-gcc42
  rvm pkg install openssl

这可以与现有的 Xcode 4.2+ 安装或 Xcode 命令行工具并存。

And you can always do

你总能做到

$ brew cleanup [specific-formula or without-formula to clean all]

and then if necessary

然后如果有必要

$ brew remove apple-gcc42

or any other installed program through brew (see the docs for explanation on those 2 commands), also you can

或通过 brew 安装的任何其他程序(有关这两个命令的解释,请参阅文档),您也可以

/join #machomebrew

on freenode (not #homebrew I think that is real homebrew beer and related)

在freenode上(不是#homebrew,我认为这是真正的自制啤酒和相关的)

回答by Dave Smylie

Only answering here because I can can't up vote/comment on leandro's comment on the original question. After spending days trying to get this to work, His solution was the one that finallygot it working for me:

只在这里回答是因为我无法对莱德罗对原始问题的评论进行投票/评论。在花了几天时间试图让它发挥作用之后,他的解决方案终于让我对我来说有效了:

edit3 didn'work for me (Xcode 4.2.1), but after installing readline

edit3 对我不起作用(Xcode 4.2.1),但是在安装 readline 之后

 rvm pkg install readline 

and passing an extra parameter

并传递一个额外的参数

rvm install 1.9.3 --with-gcc=clang --with-readline-dir=$rvm_path/usr 

it installed successfully.

它安装成功。

回答by JP.

Edit3 : doesn't work, Try to install the gcc separately from https://github.com/kennethreitz/osx-gcc-installer/downloads

Edit3:不起作用,尝试从https://github.com/kennethreitz/osx-gcc-installer/downloads单独安装 gcc

回答by Raj Pawan Gumdal

Download and use JewelryBoxThe official RVM GUI for Mac OS. Inside "Add Ruby" select your version of Ruby. Before installing, make sure you select "Use Clang" just as what Edit 3of the accepted answer in this thread suggests.

下载并使用JewelryBoxMac OS 的官方 RVM GUI。在“添加 Ruby”中选择您的 Ruby 版本。在安装之前,请确保您选择“使用 Clang”,正如该线程中已接受答案的Edit 3所建议的那样。

回答by Leon Guan

Got same issue, since I am using xcode 4.3.2 and Lion 10.7.3, and I changed my laptop few days ago and then transfer all contents from the old laptop. Apparently, some of binaries not get transfer over, such as gcc.

遇到同样的问题,因为我使用的是 xcode 4.3.2 和 Lion 10.7.3,几天前我更换了笔记本电脑,然后从旧笔记本电脑传输了所有内容。显然,一些二进制文件没有传输过来,比如 gcc。

ANd then I did following:

然后我做了以下事情:

  1. Remove Xcode 4.3.2 by dragging it to trash
  2. Download the gcc install package v2 from https://github.com/kennethreitz/osx-gcc-installer/downloads
  3. Install it
  4. Then rvm install 1.9.2 working for me
  1. 通过将 Xcode 4.3.2 拖到垃圾箱来删除它
  2. https://github.com/kennethreitz/osx-gcc-installer/downloads下载 gcc 安装包 v2
  3. 安装它
  4. 然后 rvm install 1.9.2 对我来说有效