Unable to install therubyracer on centos (errors with V8 and GCC)
Asked Answered
A

1

5

I'm trying to install therubyracer on my centos server and i'm having hella problems.

$ 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

So then i tried to install this:

[root@allthingswebdesign current]# gem install libv8
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
    ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
creating Makefile
which: no g++44 in (/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)
which: no g++46 in (/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)
which: no g++48 in (/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Traceback (most recent call last):
  File "build/gyp/gyp", line 15, in ?
    import gyp
  File "build/gyp/pylib/gyp/__init__.py", line 8, in ?
    import gyp.input
  File "build/gyp/pylib/gyp/input.py", line 14, in ?
    import gyp.common
  File "build/gyp/pylib/gyp/common.py", line 375
    with open(source_path) as source_file:
            ^
SyntaxError: invalid syntax
gmake: *** [out/Makefile.x64] Error 1
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64 -Dhost_arch=x64


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/gems/libv8-3.11.8.4 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p125@famnfo/gems/libv8-3.11.8.4/ext/libv8/gem_make.out
[root@allthingswebdesign current]# 

Output of which 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++

Info you asked for:

[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]# 

EDIT After using @Chris's solution, i now get libv8 to install, but therubyracer still doesn't install and gives me this:

[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
Alinealinna answered 10/12, 2012 at 0:45 Comment(7)
Thanks for the output... I'm adding info to my answer now, so please reload to see it.Trussell
My g++ version is only 4.1.2 even after i ran your yum command.Alinealinna
When I had the same question, the answer turned out to be "use Node.js".Bergson
@MichaelHampton i would try that, but i can't figure out how to install that either. There is no package for centos that i can find and when i try it manually i get an error when trying to ./configureAlinealinna
One q/a for node is here: serverfault.com/questions/299288/…Mulatto
fyi rubytheracer is a lot bigger than node which is more streamlined.Mulatto
I tried that but i hit an error when running ./configureAlinealinna
B
8

libv8 fails to install because Centos ships with Python 2.4. You need at least Python 2.6 to compile it. You can do this with:

yum install python26
ln -s /usr/bin/python26 /usr/local/bin/python

More simply, you can install libv8 from its binary package:

gem install libv8 --version=3.11.8.3

That said, even with that done, therubyracer may or may not install even with libv8 installed; I've been having sporadic issues with it, but only on some machines, and haven't yet been able to figure out the common root cause. I've resorted to compiling node.js on those machines instead.

Bookmark answered 10/12, 2012 at 3:58 Comment(4)
Well gem install libv8 --version=3.11.8.3 worked great, but gem install therubyracer still doesn't install like you said. I do get a different error now. I will post that at the bottom of the question.Alinealinna
You have the same issue with the install that I dead-ended on. I don't have a solution to therubyracer v0.11.0 failing to install even after a successful libv8 install, I'm sorry to say. I banged my head against it for the better part of the weekend. One alternative would be to just gem install therubyracer --version=0.10.2, but that is an older version of libv8 it uses. That should install fine though, if that's acceptable.Bookmark
gem install therubyracer --version=0.10.2 worked great. Thank you for your help as i'm now back up and running after wasting like 6 hours today.Alinealinna
This worked great. Thanks. I uninstalled therubyracer and libv8, then following these and @Alinealinna help, I was able to get my app up and running again. ThanksLinked

© 2022 - 2024 — McMap. All rights reserved.