therubyracer install error
Asked Answered
D

14

40

As you can see below, libv8 installs fine, but therubyracer doesn't. I'm using Mac 10.7.4.

~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1> gem install libv8
Building native extensions.  This could take a while...
Successfully installed libv8-3.11.8.3
1 gem installed
Installing ri documentation for libv8-3.11.8.3...
Installing RDoc documentation for libv8-3.11.8.3...

~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1> gem install therubyracer
Building native extensions.  This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

        /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for main() in -lobjc... *** 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=/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
    --with-objclib
    --without-objclib
/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
    from extconf.rb:10:in `<main>'


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

Here's the mkmf.log, which is located in ~/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/gems/1.9/gems/therubyracer-0.10.1/ext/v8>.

File Edit Options Buffers Tools Help

"/usr/bin/gcc-4.2 -o conftest -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/rub\
y/backward -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. -I/Users/rdp/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE    -O3 -ggdb -Wextra -Wno-unused-\
parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-functio\
n-declaration  -fno-common -pipe conftest.c  -L. -L/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib -L/Users/rdp/.rvm/usr/lib -L.      -lruby.1.9.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
Diluvial answered 22/7, 2012 at 8:4 Comment(0)
G
88

You can use the Libv8 from the brew instead of the one from gem. You can do that by following commands:

$ gem uninstall libv8
$ brew install v8
$ gem install therubyracer
Goulden answered 29/12, 2012 at 9:23 Comment(2)
If you need to install a specific version of therubyracer, specify it here. gem install therubyracer -v '0.11.4 (with your version number here) instead of gem install therubyracerCurculio
Worked for me as well.Resolute
I
13

@Haegin's answer in https://github.com/cowboyd/libv8/issues/205

brew uninstall v8
brew install v8-315
gem uninstall -a libv8
gem uninstall -a therubyracer
gem install libv8 -v '3.16.14.17' -- --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-v8-dir=$(brew --prefix v8-315)
Illfated answered 12/4, 2019 at 5:44 Comment(1)
I looked for several ways to solve this problem and this was the only one that worked for my macOS Monterey. Thank you.Ardra
T
10

For an older project I had to used the 0.10.1 version of rubyracer on mavericks (bootstrap depends on it)

So I had to use an older version of gcc

  1. edit your .zshrc or .bashrc

    export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
    export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
    export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
    
  2. be sure that you have uninstalled all older versions of libv8

    gem uninstall libv8
    
  3. install your version of therubyracer

    gem install therubyracer -v=0.10.1
    
Trover answered 30/1, 2014 at 10:3 Comment(0)
S
5

For Linux:

The code below is of course correct

$ gem uninstall libv8

$ gem install therubyracer

But sometimes it does't help because you haven't program make. AT FIRST you need install make. To do this, run:

sudo apt-get install build-essential

And only after that:

gem install therubyracer

Schermerhorn answered 29/6, 2017 at 12:57 Comment(1)
Thanks!! this is the answre that solve all my problemsGaige
C
4

On Mavericks, you just need to update to therubyracer 0.12.0

Cartier answered 21/1, 2014 at 19:43 Comment(0)
W
3

These steps worked for me:

  • brew uninstall v8
  • brew install v8-315
  • gem uninstall -a libv8
  • gem uninstall -a therubyracer
  • gem install libv8 -v '3.16.14.19' -- --with-system-v8
  • gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix v8-315)
Whizbang answered 7/1, 2021 at 16:30 Comment(1)
thanks, this worked: MacOS BigSur, rbenv, ruby 2.5Packer
S
2

Mac 10.10.5, Ruby 2.1.0 this worked for me:

gem uninstall libv8
gem uninstall therubyracer

brew upgrade gcc
brew install v8

bundle config --local build.libv8 --with-cxx=/usr/local/bin/gcc-6
gem install libv8 -v '3.16.14.17' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install # worked !
Sensorimotor answered 8/2, 2017 at 15:36 Comment(0)
R
1

The solution that worked for me was putting these steps together on 10.7.4

export CC=gcc-4.2

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

gem uninstall libv8
gem install therubyracer
Rambert answered 1/10, 2012 at 14:8 Comment(0)
C
0

I've had the exact same issue just till now.

This link saved me.

to sum up, you need to do this:

$ gem uninstall libv8
$ gem install therubyracer

before i fixed this issue, i had v8 installed in my mac. i don't know if this helped, since it seems have sth to do with js interpreter, I thought it might help.

Cuyler answered 22/7, 2012 at 10:5 Comment(0)
B
0

On Mountain Lion 10.8, it doesn't come preinstalled with a C compiler. You'll need to download and install the 'command line tools' package from Apple themselves, and then run which gcc to confirm it is installed. Everything should run fine from there on in.

Boyse answered 20/12, 2012 at 22:39 Comment(1)
Im also on mountain lion, and even with comand line tools I'm getting this error. I am able to individually install the gems, but not via a bundle. Any ideas?Delfeena
D
0

On OS X 10.7 I actually found that the "Command Line Tools" package wasn't enough, I had to install the full-blown XCode package, then gem install worked.

Deceive answered 24/3, 2013 at 15:20 Comment(0)
E
0

I had this same problem when I upgraded from OSX Mountain Lion to OSX Mavericks.

Upgrading from ruby-1.8.7-p354 to ruby-1.8.7-375 did the trick for me. If you are on ruby-1.93-p125, you may want to try upgrading to 1.9.3-rc1 (which is above p484 already)

libv8 (3.16.14.3-x86_64-darwin-13) and the therubyracer (0.12.0) gems installed without problem.

assuming you use rbenv:

rbenv install 1.9.3-rc1
rbenv rehash
rbenv shell 1.9.3-rc1
bundle install
Existence answered 5/4, 2014 at 3:15 Comment(0)
A
0

According to https://github.com/cowboyd/therubyracer/issues/420#issuecomment-253592865

gem uninstall therubyracer
gem uninstall libv8
brew uninstall v8
brew install v8
gem install libv8
gem install therubyracer

It helped me. Parameters: ruby 2.3.3, rails 4.2.9

Allanallana answered 28/6, 2018 at 8:54 Comment(0)
S
0

Install v8:

brew install [email protected]

After install gem libv8:

gem install libv8 -v 3.16.14.19 -- --with-system-v8

And install specific version of therubyracer:

gem install therubyracer  -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]
Scroggins answered 4/5, 2022 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.