在Mac OSX 10.8.2上安装ruby 1.9.3

时间:2012-12-27 04:01:40

标签: ruby macos

我正在尝试在我的新Mac上安装Ruby,但我遇到了一些问题,并且想知道是否有人可以提供帮助?

主要错误是:

Right now Ruby requires gcc to compile, but Xcode 4.2 and later no longer ship with gcc.
Instead they ship with llvm-gcc (to which gcc is a symlink) and clang, neither of which are
supported for building Ruby. Xcode 4.1 was the last version to ship gcc, which was
/usr/bin/gcc-4.2.

我尝试使用此帖子“Cannot install ruby-1.9.2 in Mac OSX 10.8.1 due to symlink error”中的建议来解决错误,但即使在通过自制软件安装gcc后,我仍然会收到上述错误。

当我输入gcc - v时,我收到以下消息:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/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.11~67/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.11.00)

最后,我检查了我的/ usr / bin文件夹,我看到一个大约104KB的gcc-4.2 unix可执行文件。这是我应该拥有的吗?

3 个答案:

答案 0 :(得分:2)

尝试此操作,让rvm知道要使用哪个gcc

CC=/usr/bin/gcc-4.2 rvm install 1.9.3 

或者,如果您想使用Homebrew安装的gcc

CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3

这取决于gcc-4.2解释器的位置。

两种选择:

rvm install 1.9.3 --with-gcc=clang

或使用ruby-build

编辑2013年9月7日:我非常喜欢安装Rubies的另一个选择是ruby-install。这符合同一作者chruby的精神。简单并且能很好地完成工作。

答案 1 :(得分:1)

我没有声誉尚未发表评论,但我只想注意根据Telemachus评论这对我有用 rvm install 1.9.3 --with-gcc = clang

我正在运行os x 10.8.4

答案 2 :(得分:0)

首先应安装xcode命令行工具,您可以在xcode偏好设置的“下载选项卡”中找到。

enter image description here

然后安装自制软件,这是一个像yum一样的软件包管理器,你可以用它来安装git等。

然后安装rvm,然后使用rvm install ruby

相关问题