在Mountain Lion上安装Ruby 1.8.7(10.8)

我在山狮的干净安装上安装Ruby 1.8.7时遇到了很多麻烦。 我查看了Stack Overflow并没有看到任何专门解决这个问题的内容,并希望有人可能之前遇到过这个问题。

我正在使用可以使用Xcode下载的命令行工具

通过RVM和HomeBrew安装Ruby 1.9.3没有任何问题。 当我尝试安装1.8.7时,我尝试编译后收到以下消息:

我第一次运行命令

rvm install 1.8.7 

这给了我这个错误

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

挖了一下后我试了一下

 rvm install 1.8.7 --with-gcc=clang Error running 'make ', please read /Users/paulzaich/.rvm/log/ruby-1.8.7-p370/make.log There has been an error while running make. Halting the installation. Ruby 'ruby-1.8.7-p370' was built using clang - but it's not (fully) supported, expect errors. Please be aware that you just installed a ruby that requires 2 patches just to be compiled on up to date linux system. This may have known and unaccounted for security vulnerabilities. Please consider upgrading to Ruby 1.9.3-194 which will have all of the latest security patches. 

此时我做了一些搜索,发现需要编译我自己的readline的东西。 RVM无法在Snow Leopard上安装Ruby 1.9.2:’运行’make’时出错

不幸的是,这似乎破坏了我的整个rvm安装,包括1.9.3。 我尝试重新安装1.9.3并得到了与1.8.7相同的错误。 我此时完全删除了RVM并重新安装。 没有问题再次安装1.9.3。

我还尝试使用Mountain Lion更新所有版本的rvm。 也没有运气。

更新:我也尝试使用REE 1.8.7的演练 ,建议安装gcc-4.2。 不幸的是没有运气。

更新2:我参考了rvm要求并安装了以下软件包

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

到现在为止还挺好。 然后我引用了这篇关于需要引用GCC编译器的post 。 我确定引用的链接可能不正确,因为我正在使用自制软件? 我在Cellar文件夹中找到了编译器并使用了以下命令

 CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 rvm install 1.8.7 

没运气。 与以前相同的错误消息。

我只想出来了! 请在SO上提到这个问题

rvm无法再在Mac OS X Mountain Lion上安装1.8.7-p352

 rvm reinstall 1.8.7 --without-tcl --without-tk 

或者,如果您有自制软件,请尝试此安装顺序。

 brew install tcl-tk rvm reinstall 1.8.7 

只是为了跟进保罗的post。 我正在运行OSX 10.8.2,没有问题就安装了1.9.3,但1.8.7-p370也失败了。 我用符号链接gcc-4.2:

 sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2 

…成功运行:

 brew install tcl 

…但是tk 失败了 :

 brewk install tk 

如果你在同一个地方,这个命令就可以了:

 CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7 --without-tk 

最新的Xcode只提供了clang – 而不是GNU gcc ,你需要安装gcc-4.2才能正确编译Ruby 1.8.7,以下命令将显示可用的选项:

 rvm requirements 

目前只有ruby 1.9.3-p125以及后来对clang支持有限,但这是有限的支持,仍然可以找到错误。