在Mac OS Lion上安装Ruby 1.9.2的问题

我正在运行Lion,利用Xcode 4,安装了RVM和自制程序,但我只能运行ruby 1.8.7

     spurvis:〜流氓$ ruby​​ -v
     ruby 1.8.7(2010-01-10 patchlevel 249)[universal-darwin11.0]
     spurvis:〜流氓$ 

我已经阅读了几个与此主题相关的线程,但似乎没有任何问题可以解决我的问题:

     spurvis:〜流氓$ rvm安装1.9.2
    从源代码安装Ruby到:/Users/rogue/.rvm/rubies/ruby-1.9.2-p290,这可能需要一段时间,具体取决于你的cpu ...

     ruby-1.9.2-p290  -  #fetching 
     ruby-1.9.2-p290  -  #extracted to /Users/rogue/.rvm/src/ruby-1.9.2-p290(已提取)
    将yaml-0.1.4.tar.gz提取到/Users/rogue/.rvm/archives
    将yaml-0.1.4.tar.gz解压缩到/Users/rogue/.rvm/src
    在/Users/rogue/.rvm/src/yaml-0.1.4中配置yaml。
    在/Users/rogue/.rvm/src/yaml-0.1.4中编译yaml。
    将yaml安装到/Users/rogue/.rvm/usr
     ruby-1.9.2-p290  -  #configuring 
     ruby-1.9.2-p290  -  #compiling 
    错误:运行'make'时出错,请阅读/Users/rogue/.rvm/log/ruby-1.9.2-p290/make.log
    错误:运行make时出错。 暂停安装。

make.log给了我以下信息:

     [2011-08-08 11:50:52] make
     /usr/bin/gcc-4.2 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initial
     rbconfig.rb不变
     ./miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb ./enc/make_encmake.rb  -  builtin-encs =“ascii.o us_ascii.o unicode。 o utf_8。
     ./miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb -I。  ./tool/compile_prelude.rb ./prelude.rb ./enc/prelude.rb ./gem_prelude
     /usr/bin/gcc-4.2 -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initial
     ar rcu libruby.1.9.1-static.a dln.o encoding.o version.o array.o bignum.o class.o compar.o complex.o dir.o dln_find.o enum.o enumera
     /usr/bin/gcc-4.2 -dynamiclib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name / Users / r
     :-w -L'Init_ *'-L'* _threadptr_ *'libruby.1.9.1.dylib
     ./miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h。 tmpl ./enc enc
     encdb.h不变
     make -f enc.mk RUBY =“./ miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb"MINIRUBY =”./ miniruby -I./lib- I.ext / common -I./- -r
     make [1]:对于'enc'没什么可做的。
     make -f enc.mk RUBY =“./ miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb"MINIRUBY =”./ miniruby -I./lib- I.ext / common -I./- -r
     make [1]:对于`srcs'没什么可做的。
 ./miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb ./tool/generic_erb.rb -c -o transdb.h ./template/transdb.h。 tmpl ./enc/tra
     transdb.h不变
     make -f enc.mk RUBY =“./ miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb"MINIRUBY =”./ miniruby -I./lib- I.ext / common -I./- -r
     make [1]:对于./enc/trans'没什么可做的。
 make -f enc.mk RUBY =“./ miniruby -I./lib -I.ext / common -I./- -r./ext/purelib.rb"MINIRUBY =”./ miniruby -I./lib- I.ext / common -I./- -r
     mkdir -p .ext / x86_64-darwin11.0.0 / enc .ext / x86_64-darwin11.0.0 / enc / trans enc enc / trans
    编译-test- / bug-3662
     make [1]:没有什么可以为'所有'做。
    编译-test- / string
     make [1]:没有什么可以为'所有'做。
    编译bigdecimal
     make [1]:没有什么可以为'所有'做。
    编译继续
     make [1]:没有什么可以为'所有'做。
    编制报道
     make [1]:没有什么可以为'所有'做。
    编译诅咒
    
    编译openssl
     /usr/bin/gcc-4.2 -I。  -I ../../。\ text / include / x86_64-darwin11.0.0 -I ../.././ include  -  I ../.././ ext / openssl -DRUBY_EXTCONF_H = \“extconf.h \”
     ossl_bio.c:在函数'ossl_obj2bio'中:
     ossl_bio.c:26:错误:被称为对象'“。rnd”'不是函数
     ossl_bio.c:42:警告:隐式转换将64位值缩短为32位值
     make [1]:*** [ossl_bio.o]错误1
     make:*** [mkmain.sh]错误1

根据其他建议,我尝试将导出CC = / usr / bin / gcc-4.2添加到我的bashrc,但这也没有解决问题。

请帮忙!

确保你有最新的xcode(如果你正在运行雪豹的副本,你需要更新它。更新RVM rvm get head ,然后再试一次。

我在编译ree时遇到问题,但1.9.2工作正常,你可以尝试在你的主目录中将此函数添加到.profile,它将使用gcc编译(而不是默认的LLVM)

 # using_gcc for 64btt compiling on lion (solves compatability issues) function using_gcc() { env CC="/usr/bin/gcc-4.2" ARCHFLAGS="-arch x86_64" ARCHS="x86_64" $* } 

然后运行using_gcc rvm install 1.9.2

如果你正在运行Lion&Xcode 4.2的全新副本,那么你首先需要安装GCC 4.2 dev库 – 它们不包含在新的Xcode 4.2安装中。

然后在安装rvm时传递CC="/usr/bin/gcc-4.2"标志。

请务必rvm remove任何先前的安装尝试。

如果你想用ruby 1.8.7获得rvm install ree来工作,这解决了我的问题:

 # using_gcc for 32btt compiling on lion (solves compatability issues) function using_gcc() { env CC="/usr/bin/gcc-4.2" ARCHFLAGS="-arch x86_32" ARCHS="x86_32" $* } #then using_gcc rvm install ree 

基本上只是在另一个答案中将“64”改为“32”。