centos 上的 rvm 安装 ruby 2.2.0

Rvm install ruby 2.2.0 on centos

在 centos 5 上通过 rvm 安装 ruby 2.2.0 时出现奇怪的错误。

这是安装日志:

[deployer@p241408 asiniy]$ rvm list
   ruby-2.1.0 [ i686 ]
=* ruby-2.1.1 [ i686 ]

我尝试删除以前安装的缓存:

[deployer@p241408 asiniy]$ rvm remove 2.2.0
ruby-2.2.0 - #removing src/ruby-2.2.0..

重置 RVM 并安装

[deployer@p241408 asiniy]$ rvm reset
[deployer@p241408 asiniy]$ rvm install 2.2
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/5/i386/ruby-2.2.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /home/deployer/.rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)...
ruby-2.2.0 - #downloading ruby-2.2.0, this may take a while depending on your connection...
ruby-2.2.0 - #extracting ruby-2.2.0 to /home/deployer/.rvm/src/ruby-2.2.0....
ruby-2.2.0 - #applying patch /home/deployer/.rvm/patches/ruby/2.2.0/fix_installing_bundled_gems.patch.
ruby-2.2.0 - #configuring.........................................................
ruby-2.2.0 - #post-configuration..
ruby-2.2.0 - #compiling..............
Error running '__rvm_make -j1',
showing last 15 lines of /home/deployer/.rvm/log/1425194973_ruby-2.2.0/make.log
            (use (reg:SI 19 dirflag))
        ]) 528 {*rep_movsi} (insn_list:REG_DEP_TRUE 8516 (insn_list:REG_DEP_TRUE 8521 (insn_list:REG_DEP_TRUE 8522 (nil))))
    (expr_list:REG_UNUSED (reg/f:SI 2548 [ block ])
        (expr_list:REG_UNUSED (reg/f:SI 2547 [ proc ])
            (expr_list:REG_UNUSED (reg:SI 2 cx [2550])
                (expr_list:REG_DEAD (reg:SI 19 dirflag)
                    (expr_list:REG_DEAD (reg/v/f:SI 1033 [ blockptr ])
                        (expr_list:REG_DEAD (reg:SI 2 cx [2549])
                            (expr_list:REG_UNUSED (reg/f:SI 2548 [ block ])
                                (expr_list:REG_UNUSED (reg/f:SI 2547 [ proc ])
                                    (expr_list:REG_UNUSED (reg:SI 2 cx [2550])
                                        (nil)))))))))))
vm_exec.c:127: confused by earlier errors, bailing out
make: *** [vm.o] Error 1
++ return 2
There has been an error while running make. Halting the installation.

这是日志文件中的整个错误:

[deployer@p241408 ~]$ tail -n 200 /home/deployer/.rvm/log/1425194973_ruby-2.2.0/make.log
[2015-03-01 02:33:04] __rvm_make
__rvm_make () 
{ 
    \make "$@" || return $?
}
current path: /home/deployer/.rvm/src/ruby-2.2.0
PATH=/home/deployer/.rvm/usr/bin:/home/deployer/.rvm/bin:/home/deployer/bin:/home/deployer/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/deployer/bin
command(2): __rvm_make -j1
++ make -j1
    CC = gcc
    LD = ld
    LDSHARED = gcc -shared
    CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -std=iso9899:1999 -fPIC -march=i486
    XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS =   -I. -I.ext/include/i686-linux -I./include -I.
    DLDFLAGS = -Wl,-soname,libruby.so.2.2  -fstack-protector  -march=i486
    SOLIBS = -lpthread -lrt -ldl -lcrypt -lm  
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
compiling main.c
compiling dmydln.c
compiling miniinit.c
compiling miniprelude.c
copying dummy probes.h
compiling array.c
compiling bignum.c
compiling class.c
class.c: In function ‘rewrite_cref_stack’:
class.c:238: warning: dereferencing type-punned pointer will break strict-aliasing rules
class.c: In function ‘clone_method’:
class.c:260: warning: dereferencing type-punned pointer will break strict-aliasing rules
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling encoding.c
compiling enum.c
enum.c: In function ‘sort_by_i’:
enum.c:840: warning: dereferencing type-punned pointer will break strict-aliasing rules
enum.c: In function ‘enum_sort_by’:
enum.c:974: warning: dereferencing type-punned pointer will break strict-aliasing rules
compiling enumerator.c
compiling error.c
compiling eval.c
compiling load.c
compiling proc.c
compiling file.c
compiling gc.c
compiling hash.c
compiling inits.c
compiling io.c
compiling marshal.c
compiling math.c
compiling node.c
compiling numeric.c
compiling object.c
compiling pack.c
compiling parse.c
compiling process.c
compiling random.c
compiling range.c
compiling rational.c
compiling re.c
compiling regcomp.c
compiling regenc.c
compiling regerror.c
compiling regexec.c
compiling regparse.c
compiling regsyntax.c
compiling ruby.c
compiling safe.c
compiling signal.c
compiling sprintf.c
In file included from sprintf.c:1255:
vsnprintf.c: In function ‘BSD_vfprintf’:
vsnprintf.c:822: warning: comparison of unsigned expression < 0 is always false
compiling st.c
compiling strftime.c
compiling string.c
compiling struct.c
compiling symbol.c
compiling time.c
compiling transcode.c
compiling util.c
compiling variable.c
compiling version.c
compiling compile.c
compiling debug.c
compiling iseq.c
iseq.c: In function ‘set_relation’:
iseq.c:228: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c:235: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c:236: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c:241: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c:247: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c: In function ‘rb_iseq_clone’:
iseq.c:1977: warning: dereferencing type-punned pointer will break strict-aliasing rules
iseq.c:1981: warning: dereferencing type-punned pointer will break strict-aliasing rules
compiling vm.c
In file included from vm.c:77:
vm_insnhelper.c: In function ‘vm_cref_push’:
vm_insnhelper.c:276: warning: dereferencing type-punned pointer will break strict-aliasing rules
vm_insnhelper.c:279: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from vm_exec.c:120,
                 from vm.c:79:
insns.def: In function ‘vm_exec_core’:
insns.def:994: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from vm.c:82:
vm_eval.c: In function ‘eval_string_with_cref’:
vm_eval.c:1281: warning: dereferencing type-punned pointer will break strict-aliasing rules
vm.c: In function ‘vm_define_method’:
vm.c:2260: warning: dereferencing type-punned pointer will break strict-aliasing rules
vm_exec.c: In function ‘vm_exec_core’:
vm_exec.c:127: error: unable to find a register to spill in class ‘SIREG’
vm_exec.c:127: error: this is the insn:
(insn:HI 8524 8522 8525 1038 vm.c:644 (parallel [
            (set (reg:SI 2 cx [2550])
                (const_int 0 [0x0]))
            (set (reg/f:SI 2547 [ proc ])
                (plus:SI (ashift:SI (reg:SI 2 cx [2549])
                        (const_int 2 [0x2]))
                    (reg:SI 5 di [orig:1030 D.47274 ] [1030])))
            (set (reg/f:SI 2548 [ block ])
                (plus:SI (ashift:SI (reg:SI 2 cx [2549])
                        (const_int 2 [0x2]))
                    (reg/v/f:SI 1033 [ blockptr ])))
            (set (mem/s:BLK (reg:SI 5 di [orig:1030 D.47274 ] [1030]) [13 <variable>.block+0 S20 A32])
                (mem/s:BLK (reg/v/f:SI 1033 [ blockptr ]) [13 S20 A32]))
            (use (reg:SI 2 cx [2549]))
            (use (reg:SI 19 dirflag))
        ]) 528 {*rep_movsi} (insn_list:REG_DEP_TRUE 8516 (insn_list:REG_DEP_TRUE 8521 (insn_list:REG_DEP_TRUE 8522 (nil))))
    (expr_list:REG_UNUSED (reg/f:SI 2548 [ block ])
        (expr_list:REG_UNUSED (reg/f:SI 2547 [ proc ])
            (expr_list:REG_UNUSED (reg:SI 2 cx [2550])
                (expr_list:REG_DEAD (reg:SI 19 dirflag)
                    (expr_list:REG_DEAD (reg/v/f:SI 1033 [ blockptr ])
                        (expr_list:REG_DEAD (reg:SI 2 cx [2549])
                            (expr_list:REG_UNUSED (reg/f:SI 2548 [ block ])
                                (expr_list:REG_UNUSED (reg/f:SI 2547 [ proc ])
                                    (expr_list:REG_UNUSED (reg:SI 2 cx [2550])
                                        (nil)))))))))))
vm_exec.c:127: confused by earlier errors, bailing out
make: *** [vm.o] Error 1
++ return 2

这看起来像是 ruby 本身的错误,请在此处报告:https://bugs.ruby-lang.org/projects/ruby-trunk/issues 也可以尝试使用 ruby-head - 并将结果包含在报告中。

解决方法很简单。我没有尝试安装 2.2.0,而是安装了刚刚发布的版本 2.2.1

所以,

rvm install 2.2.1