"gem install therubyracer -v '0.10.2'" on osx mavericks not installing
Asked Answered
C

12

91

Trying to install therubyracer on mavericks using "gem install therubyracer -v '0.10.2'" but i am getting the following error:

/Users/dennischen/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for main() in -lobjc... yes
creating Makefile

make
compiling rr.cpp
clang: warning: argument unused during compilation: '-rdynamic'
rr.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling v8.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_array.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_callbacks.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_context.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_date.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_debug.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_exception.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_exception.cpp:10:16: warning: unused variable 'stack' [-Wunused-variable]
  static void* stack[20];
               ^
1 warning generated.
compiling v8_external.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_external.cpp:10:9: warning: unused variable 'references' [-Wunused-variable]
  VALUE references;
        ^
1 warning generated.
compiling v8_function.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_handle.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_locker.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_locker.cpp:45:5: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
v8_locker.cpp:85:5: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
2 warnings generated.
compiling v8_message.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_object.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_object.cpp:77:19: warning: unused variable 'proto' [-Wunused-variable]
    Handle<Value> proto(rr_rb2v8(prototype));
                  ^
1 warning generated.
compiling v8_script.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_string.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_template.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_try_catch.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_v8.cpp
clang: warning: argument unused during compilation: '-rdynamic'
compiling v8_value.cpp
clang: warning: argument unused during compilation: '-rdynamic'
v8_value.cpp:100:9: warning: unused function 'ToInt32' [-Wunused-function]
  VALUE ToInt32(VALUE self) {
        ^
1 warning generated.
compiling v8_weakref.cpp
clang: warning: argument unused during compilation: '-rdynamic'
linking shared-object v8.bundle
clang: error: no such file or directory: '/Users/dennischen/.rvm/gems/ruby-1.9.3-p194@panini/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'
make: *** [v8.bundle] Error 1

can anyone help me figure out how to get this gem to work? I have the command line tools installed.

Clobber answered 28/10, 2013 at 8:33 Comment(2)
Do you have homebrew? Try installing v8 using brew install v8 before installing gemLangobard
I believe the brew install v8 is a separate issue. Please see https://mcmap.net/q/121342/-therubyracer-install-error for details on v8 with brew.Treiber
E
242

If you decide to use a newer therubyracer gem version, you will no longer have this problem

Otherwise:

brew tap homebrew/dupes # Thanks Tom
brew install apple-gcc42

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

brew uninstall v8

gem uninstall libv8

gem install therubyracer -v '0.10.2' # specify version
Ensconce answered 22/11, 2013 at 12:48 Comment(13)
This approach seems better than modifying symlinksAbacus
Error: No available formula for apple-gcc42Cheerful
brew tap homebrew/dupes fixes "Error: No available formula for apple-gcc42"Defamation
This FINALLY fixed the issue for me — thanks! I tried M. Scott Ford's symlink solution below and it appeared to work, but threw an error when I actually tried to do anything (rake, rails, etc).Annelieseannelise
Yer updating to therubyracer 0.12.0 fixed this issue for me.Improper
I had to add RUBYOPT=-rrubygems too, similarly to this questionRicer
Worked perfectly for me (using bundle install too).Hernardo
exporting CC, CXX and CPP worked for me. Thanks. Installing another, more recent version of therubyracer worked as well, but as i'm i can not update the Gem Version in one of the projects: thanks a bunch:-)Oxendine
Unfortunately, none of these solutions is working for me on OSX 10.9, ruby 2.1.0, and therubyracer 0.12.1.Induction
Worked on OS X 10.11 as well.Elgar
I'm getting apple-gcc42: This formula either does not compile or function as expected on macOS when I run brew install apple-gcc42Paduasoy
Using macOS Version 10.12.6Paduasoy
I'm having a similar problem, but this solution isn't working. Any ideas? #46104563Paduasoy
A
16

So I finally got it working after some struggling... thanks to Simon and Alvaro.

I have one thing to add though, using the flag --with-system-v8 did not work for me... So i removed my system v8 with

brew uninstall v8

And the run

gem install libv8

If you have already run gem install libv8 with the system v8 flag be sure to uninstall that gem version (do it by running gem uninstall libv8). The important thing is that you shouldn't use the one provided by brew, it does not seem to work in Mavericks (it gets installed well and bundler will report that your bundle is complete, but your app will fail when it tries to use v8).

To summarize the answer, doing the following worked for me:

brew install apple-gcc42
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp

brew uninstall v8
gem install libv8
gem install therubyracer
Attaint answered 4/11, 2013 at 6:47 Comment(2)
This worked for me. But I symlinked gcc into /usr/local/bin and restarted terminal so I could remove it after I installed libv8.Compaction
Symlinking homebrew binaries with that specific version, into /usr/bin, is a really bad idea. The next brew update that comes along and revs those paths will leave you in a broken state.Nerti
B
10

I had the same problem, this works for me:

therubyracer (0.10.2) & libv8 (3.3.10.4)

First of all:

  • brew install apple-gcc42
  • you must link all the binary files of the compilers (gcc, cpp, g++) to /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/<compiler>

After, you could try this:

  • brew install v8
  • gem install libv8 -v '3.3.10.4' -- --with-system-v8
  • gem install therubyracer -v 'therubyracer' or bundle install into the directory of the rails project.
Busily answered 3/11, 2013 at 18:28 Comment(1)
apple-gcc42: This formula either does not compile or function as expected on macOS My macOS is 10.12.6Paduasoy
D
7

I just had the same problem and one solution is currently to use apple-gcc42 instead of clang to compile both gems :

brew install apple-gcc42

And then you have the choice between doing some symlinks in /usr/bin for {gcc,g++,c++} binaries :

sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp

In fact g++ should be enough.

Or...you could export CC/CXX/CPP environment variables with paths corresponding to the binaries created by homebrew. That's surely a cleaner workaround.

A third solution is to download Xcode 4.6.3 and install it in the Applications folder. Then, enter in the terminal:

sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer
gem install therubyracer

Once the gem has been installed you can switch back to Xcode 5.0 :

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Donitadonjon answered 28/10, 2013 at 9:6 Comment(3)
How do I switch the compiler to apple-gcc42?Clobber
@Simon when I try to symlinc to the compilers I get a message that file exists. Is that the clang file? If I run bundle install it doesn't appear to be using gcc because the error is full of clang references.Versicolor
If you're using MacPorts you don't have to symlink to point to a different GCC version, there's a builtin command for that (see my answer).Fellner
P
6

I found a workaround that worked without installing apple-gcc42.

This will work if the error message you're getting looks like this:

clang: error: no such file or directory: '/Users/mscottford/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a'

Then you should be able to do the following:

brew install v8
bundle install 
# after failing create link from brew installed v8 to error location
ln -s /usr/local/Cellar/v8/3.21.17/lib/libv8_base.x64.a /Users/mscottford/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a
bundle install

Source: https://github.com/cowboyd/therubyracer/issues/277#issuecomment-27734348

Polyglot answered 12/11, 2013 at 13:52 Comment(2)
Huge +1 for this one. The gem would install on the CLI but RubyMine v6 was refusing to install it... setting this symlink resolved the issue finally. Thanks!Walloper
This 1000%, cheers @M.ScottFord. I use rvm and therefore my ln statement was this: ln -s /usr/local/Cellar/v8/3.21.17/lib/libv8_base.x64.a ~/.rvm/gems/ruby-1.9.3-p327/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.aDesquamate
F
3

As suggested in many answers, the easiest thing to do is to compile The Ruby Racer native extensions with Apple GCC 4.2 (instead of the version installed with Xcode).

If you're using MacPorts you shouldn't have to manually deal with setting up symbolic links for the GCC binaries. The port select command does it for you. If you haven't updated MacPorts since installing Mavericks, do a sudo port selfupdate. With MacPorts up-to-date, try the following:

# If you don't have it, install the port for Apple's GCC 4.2
sudo port install apple-gcc42 

    # OR

# If you had apple-gcc42 already (before Mavericks), update it
sudo port upgrade apple-gcc42


# Same result as manual symlinking of GCC in other answers
sudo port select gcc apple-gcc42 && hash -r

# Install therubyracer, will install libv8 gem dependency
#  *note* if you have any existing versions of these gems, remove them
gem install therubyracer

# Restore GCC to system default (optional)
sudo port select gcc none && hash -r

In general this procedure (sudo port select gcc [version]) will work any time you want to use a specific GCC version instead of the one installed by Xcode (Apple LLVM v5 for 10.9 Mavericks/Xcode 5).

Fellner answered 18/11, 2013 at 17:33 Comment(1)
Worked for me on mavericks.Mohair
J
3

I manage to install therubyracer 0.12 and libv8 3.16.14.3 on ruby 2.0.0p353 and os x 10.9

libv8 requires gcc42

brew install v8
brew install apple-gcc42
sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 /usr/bin/gcc
sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 /usr/bin/g++
sudo ln -sf /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2 /usr/bin/cpp
gem install libv8

therubyracer requires later gcc

brew install gcc49
sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/gcc-4.9 /usr/bin/gcc
sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/g++-4.9 /usr/bin/g++
sudo ln -sf /usr/local/Cellar/gcc49/4.9-20131110/bin/cpp-4.9 /usr/bin/cpp

Gemfile

gem 'therubyracer', :require => 'v8', :platforms => :ruby

use bundle instead of gem install therubyracer

Judaic answered 24/11, 2013 at 10:14 Comment(1)
Thanks! This finally got me past bundle install after days of trial and error. Only thing I did differently was to uninstall all of the developer tools that were installed by brew until gcc --version reported that it was the Apple LLVM version and was configured with Xcode, then I moved the existing /usr/bin/gcc (et. al.) out before symlinking the apple-gcc42 libs, then instead of installing gcc49 (last time I tried it took over an our to configure) I just copied the original gcc, g++, and cpp libs back. Given that I tried 3 dozen different ways to find the one that worked for me, YMMVSupersede
H
3

This should be a failsafe and clean way (no symlinks) to to install therubyracer for anyone having trouble.

Taken from: gem install therubyracer -v 0.11.4 fails on OS X 10.10

install Xcode (if you don't already have one of these versions) 6.1.1, 6.2-beta or 6.3-beta and (this one is needed) 4.6.3

gem uninstall libv8 if you haven't already done so

switch to Xcode 4.6.3

sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer

gem install libv8 -v '3.11.8.17' Or whichever version is tied to your version of therubyracer

switch to Xcode 6.1.1, 6.2-beta or 6.3-beta (or if you want to try your current install of Xcode, adjust this line, I've confirmed all 3 of these work)

sudo xcode-select --switch /Applications/Xcode6.1.1.app/Contents/Developer

gem install therubyracer -v '0.11.4' or the version you're trying to install.

Hilburn answered 3/2, 2015 at 19:11 Comment(2)
Thanks @th01 this worked for me...I tried everything I could find for 3 hours...in my case, it was the libv8 gem. Downloaded Xcode4.6.3 and ran it with that version and it was installed successfully. Here is a link with a quick tutorial on how to install multiple Xcode versions: blogs.oracle.com/mobile/entry/how_to_install_multiple_xcodesKrysta
When I download Xcode 4.6.3 and then run sudo xcode-select --switch /Applications/Xcode4.6.3.app/Contents/Developer and then run gem install libv8 -v '3.3.10.4' I get: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly! What am I doing incorrectly?Paduasoy
O
1

I had a nearly identical error when trying to install therubyracer 0.12.0 to get it to work with libv8. This worked for me:

$ brew upgrade gcc

$ gem uninstall therubyracer

$ gem uninstall libv8

$ gem install therubyracer -v '0.12.0'
Fetching: therubyracer-0.12.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.12.0
1 gem installed

$ gem install libv8 -v '3.16.14.3' -- --with-system-v8
Fetching: libv8-3.16.14.3.gem (100%)
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.3
1 gem installed
Opacity answered 14/1, 2016 at 8:59 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.

Maybe try upgraded from ruby 1.9.3-p194 to rc1 (1.9.3 is above p484 now)

assuming you use rbenv:

rbenv install 1.9.3-rc1
rbenv rehash
rbenv global 1.9.3-rc1
bundle install
Entophyte answered 5/4, 2014 at 3:22 Comment(0)
B
0

I had this problem after upgrading from Mavericks to Yosemite. The issue was that I compiled my Ruby version with the old version of OSX.

If I ran

ruby -rubygems -e 'puts Gem::Platform.new(RUBY_PLATFORM)'

I would get x86_64-darwin-13 instead of x86_64-darwin-14 for Yosemite.

To re-install Ruby I

  1. Completely removed old version: rvm remove ruby-2.1.1
  2. Re-installed from source (the --disable-binary doesnt use pre-compiled binaries and forces a build): rvm reinstall --disable-binary 2.1

Then I was able to run bundle install with no errors after trying all the solutions above.

Bespangle answered 30/4, 2015 at 4:28 Comment(0)
H
-2

What I did was to on osx mavericks:

git clone [email protected]:cowboyd/therubyracer.git

Then:

gem build therubyracer.gemspec
gem install therubyracer-0.12.1.gem

This procedure downloaded a binary version of libv8 and installed it.

Hyaloplasm answered 22/7, 2014 at 0:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.