Ruby on rails 无法在centos上安装therubyracer(V8和GCC错误)

Ruby on rails 无法在centos上安装therubyracer(V8和GCC错误),ruby-on-rails,ruby,therubyracer,Ruby On Rails,Ruby,Therubyracer,我试图在centos服务器上安装therubyracer,但遇到了hella问题 $ gem install therubyracer Building native extensions. This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension. /usr/local/rvm/rubies/ruby-1.

我试图在centos服务器上安装therubyracer,但遇到了hella问题

$ gem install therubyracer
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
    --with-pthreadlib
    --without-pthreadlib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --without-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/gems/therubyracer-0.11.0/ext/v8/build.rb:42:in `build_with_system_libv8': unable to locate libv8. Please see output for details (RuntimeError)
    from extconf.rb:22:in `<main>'
    The Ruby Racer requires libv8 ~> 3.11.8
    to be present on your system in order to compile
    and link, but it could not be found.

    In order to resolve this, you will either need to manually
    install an appropriate libv8 and make sure that this
    build process can find it. If you install it into the
    standard system path, then it should just be picked up
    automatically. Otherwise, you'll have to pass some extra
    flags to the build process as a hint.

    If you don't want to bother with all that, there is a
    rubygem that will do all this for you. You can add
    following line to your Gemfile:
        gem 'libv8', '~> 3.11.8'

    We hope that helps, and we apologize, but now we have
    to push the eject button on this install.

    thanks,
    The Mgmt.



Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/gems/therubyracer-0.11.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/gems/therubyracer-0.11.0/ext/v8/gem_make.out
其中g的输出++

$ which g++
/usr/bin/g++


    $ /usr/bin/g++ --version
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@allthingswebdesign current]# which g++
/usr/bin/g++
[root@allthingswebdesign current]# which g++44
/usr/bin/g++44
[root@allthingswebdesign current]# 

[root@allthingswebdesign current]# cd /usr/bin/
[root@allthingswebdesign bin]# ls -al g++*
-rwxr-xr-x 4 root root 218432 May 10  2012 g++
-rwxr-xr-x 2 root root 263704 Feb 21  2012 g++44
lrwxrwxrwx 1 root root     12 Dec  9 17:21 g++-4.4 -> /usr/bin/g++
您要求的信息:

[root@allthingswebdesign node-v0.8.15]# which gcc
/usr/bin/gcc
[root@allthingswebdesign node-v0.8.15]# which g++
/usr/bin/g++
[root@allthingswebdesign node-v0.8.15]# which g++44
/usr/bin/g++44
[root@allthingswebdesign node-v0.8.15]# ls -la /usr/bin/g++
-rwxr-xr-x 4 root root 218432 May 10  2012 /usr/bin/g++
[root@allthingswebdesign node-v0.8.15]# 
编辑 在使用@Chris的解决方案后,我现在可以安装libv8,但therubyracer仍然没有安装,并提供以下信息:

[root@allthingswebdesign famnfo.com]# gem install therubyracer
Fetching: therubyracer-0.11.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for main() in -lpthread... yes
creating Makefile

make
compiling accessor.cc
accessor.cc:181:2: warning: no newline at end of file
compiling array.cc
array.cc:26:2: warning: no newline at end of file
compiling backref.cc
backref.cc:45:2: warning: no newline at end of file
compiling constants.cc
constants.cc:34:2: warning: no newline at end of file
compiling constraints.cc
constraints.cc:52:2: warning: no newline at end of file
compiling context.cc
compiling date.cc
date.cc:18:2: warning: no newline at end of file
compiling exception.cc
exception.cc:38:2: warning: no newline at end of file
compiling external.cc
external.cc:43:2: warning: no newline at end of file
compiling function.cc
function.cc:58:2: warning: no newline at end of file
compiling gc.cc
gc.cc:43:2: warning: no newline at end of file
compiling handles.cc
handles.cc:34:2: warning: no newline at end of file
compiling heap.cc
heap.cc:31:2: warning: no newline at end of file
compiling init.cc
init.cc:39:2: warning: no newline at end of file
compiling invocation.cc
invocation.cc:86:2: warning: no newline at end of file
compiling locker.cc
locker.cc:77:2: warning: no newline at end of file
compiling message.cc
message.cc:51:2: warning: no newline at end of file
compiling object.cc
object.cc:334:2: warning: no newline at end of file
compiling primitive.cc
primitive.cc:8:2: warning: no newline at end of file
compiling rr.cc
rr.cc:83:2: warning: no newline at end of file
compiling script.cc
script.cc:80:17: warning: no newline at end of file
compiling signature.cc
signature.cc:18:2: warning: no newline at end of file
compiling stack.cc
stack.cc:76:2: warning: no newline at end of file
compiling string.cc
string.cc:47:17: warning: no newline at end of file
compiling template.cc
template.cc:175:2: warning: no newline at end of file
compiling trycatch.cc
trycatch.cc:87:2: warning: no newline at end of file
compiling v8.cc
v8.cc:87:2: warning: no newline at end of file
compiling value.cc
value.cc:239:2: warning: no newline at end of file
linking shared-object v8/init.so
/usr/bin/ld:/usr/local/rvm/gems/ruby-1.9.3-p125/gems/libv8-3.11.8.3-x86_64-linux/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a: file format not recognized; treating as linker script
/usr/bin/ld:/usr/local/rvm/gems/ruby-1.9.3-p125/gems/libv8-3.11.8.3-x86_64-linux/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a:1: syntax error
collect2: ld returned 1 exit status
make: *** [init.so] Error 1


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p125/gems/therubyracer-0.11.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p125/gems/therubyracer-0.11.0/ext/v8/gem_make.out

libv8无法安装,因为Centos附带Python 2.4。至少需要Python2.6来编译它。您可以通过以下方式执行此操作:

yum install python26
ln -s /usr/bin/python26 /usr/local/bin/python
更简单地说,您可以从其二进制软件包安装libv8:

gem install libv8 --version=3.11.8.3

也就是说,即使安装了libv8,rubyracer也可能安装,也可能不安装;我一直有零星的问题,但只是在一些机器上,还没有能够找出共同的根本原因。我转而在这些机器上编译node.js。

谢谢您的输出。。。我现在正在为我的答案添加信息,请重新加载以查看它。即使在我运行了你的yum命令之后,我的g++版本也只有4.1.2。当我运行了这个命令时,答案是“use Node.js”。@MichaelHampton我会尝试一下,但我也不知道如何安装它。我找不到适用于centos的软件包,当我手动尝试时,我在尝试配置节点时遇到了一个错误。/这里有一个q/a:好的
gem install libv8--version=3.11.8.3
工作得很好,但是
gem install therubyracer
仍然没有像您所说的那样安装。我现在确实得到了一个不同的错误。我会在问题的最下面贴出来。你的安装和我一样有问题。很抱歉,我没有解决Rubyracer v0.11.0在成功安装libv8后仍无法安装的问题的解决方案。在周末的大部分时间里,我的头都撞到了它。另一种选择是只安装rubyracer--version=0.10.2,但它使用的是旧版本的libv8。如果可以接受的话,安装应该很好。
gem-install-therubyracer--version=0.10.2
效果很好。谢谢你的帮助,我今天浪费了大约6个小时,现在已经恢复跑步了。这很有效。谢谢我卸载了therubyracer和libv8,然后根据这些和@Catfish帮助,我能够让我的应用程序重新启动并运行。谢谢
gem install libv8 --version=3.11.8.3