7

I am trying to install rails for the first time on my new macbook pro running OS X 10.9 (Mavericks) and I am running into an issue installing therubyracer. When I do "bundle install" I get this error:

An error occurred while installing therubyracer (0.10.2), and Bundler cannot continue. Make sure that gem install therubyracer -v '0.10.2' succeeds before bundling.

Then I follow their instructions and run

gem install therubyracer -v '0.10.2'

Then I get this error message:

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

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb

checking for main() in -lobjc... yes creating Makefile

make "DESTDIR=" 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 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' v8_try_catch.cpp:15:14: warning: initialization of pointer of type 'v8::TryCatch *' to null from a constant boolean expression [-Wbool-conversion] return false; ^~~~~ 1 warning generated. 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: '/Library/Ruby/Gems/2.0.0/gems/libv8-3.3.10.4/lib/libv8/build/v8/libv8.a' make: * [v8.bundle] Error 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/therubyracer-0.10.2 for inspection. Results logged to /Library/Ruby/Gems/2.0.0/gems/therubyracer-0.10.2/ext/v8/gem_make.out

I'm not really sure what this means or how to fix this.

All I really want to do is run my rails projects.

Anyone know what the issue is?

amdixon
  • 3,814
  • 8
  • 25
  • 34
Amir
  • 2,249
  • 7
  • 34
  • 48

10 Answers10

13

Do this:

$ gem uninstall libv8 # ignore if this fails
$ gem install libv8 -v 3.16.14.3 -- --with-system-v8 # 2013-08 x86_64-darwin-12 (32.6 MB)

Also edit your Gemfile and force a newer version of therubyracer

gem "therubyracer", "~> 0.12"

Then try again:

$ bundle update
Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110
  • Sorry this did not work. I get the same error when I do bundle install and the same error when I try to install therubyracer. – Amir Dec 07 '13 at 15:44
  • 1
    Nevermind you added more to your question. This worked! Thanks! – Amir Dec 07 '13 at 16:05
  • 2
    @Amir, good to hear that you resolved your issue, but I encourage you to read my post regarding one of the prior recommendations to use something like rvm. – nil Dec 07 '13 at 16:11
10

Works like a charm! Thanks https://stackoverflow.com/a/58842254/642616

$ brew install v8@3.15
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
$ bundle install

@3.15 could be replaced with any other versions.

Feuda
  • 2,335
  • 30
  • 28
3

The standard is that you not use system ruby and there are reasons why that is. Although you might be able to get this particular issue fixed remaining on the system ruby, using a ruby-manager like RVM or rbenv and along side with homebrew, you'll be able to quickly resolve any dependency issues.

It can kind of be a lengthy process because you'll first need to install Xcode and the additional command-line tools from Xcode. After that's done you'll need to get the ruby-manager.

I really like this shell script from thoughtbot and it uses rbenv - https://github.com/thoughtbot/laptop

Afterward run the thoughtbot script. It will take a while once you get it going. So go make some coffee. This will install homebrew, rbenv and setup everything.

After restarting terminal it should load your new bash_profile zsh. Run 'rbenv --help' to list the commands. For instance, you can use the command 'rbenv versions' to see what's available on the machine. Or to install 'rbenv install 2.0.0-p353' and then to set the ruby version globally you can use 'rbenv global 2.0.0-p353 or whatever current version you're using.

And you'll want to keep your patches up to date, some of which are security patches. Which is another reason for a manager. So you can easily update your systems to the latest and greatest! And as time goes on and your newer projects get newer versions, your older projects will require older versions. Not to confuse with patches, but for instance the move from ruby 1.9 to ruby 2.0. The change was significant enough, for some projects to not be practical to upgrade from ruby 1.9 with rails 3 to ruby 2.0 and rails 4. So when upgrading happens, I have to switch my version of ruby to run the application and make my changes. So just do it. Get away from the system ruby.

nil
  • 2,238
  • 1
  • 19
  • 28
  • 2
    Thank you I will spend some time and use RVM instead of the system Ruby. – Amir Dec 07 '13 at 16:21
  • @Amir, I do encourage you to try out the thoughtbot script. It will save you a lot some time. It uses rbenv, which I hadn't tried before the script. I used to use rvm and still do on a vps, but I found that I prefer rbenv. I was so tired of the process of installing ruby on osx, and this made for a much better experience. If you don't have a preference, just go with the script and rbenv. – nil Dec 07 '13 at 16:36
  • I will check out the script and rbenv. I hope it makes setting it up easily. I dislike how long this process is taking me just to setup my rails project. – Amir Dec 07 '13 at 17:36
  • 1
    Just to update you, I have switched to using RVM. :-) – Amir Dec 23 '13 at 01:52
  • I use rbenv and still had this problem – sixty4bit Nov 26 '14 at 17:38
  • @sixty4bit, did you run rbenv rehash? – nil Nov 27 '14 at 20:13
  • @Russell I don't think I did...I also don't have a full Xcode installation. I thought only Command Line Tools was the only necessary component of Xcode? – sixty4bit Nov 28 '14 at 00:55
3

This worked for me in MAC

$ gem uninstall libv8
$ gem install therubyracer

Then try

bundle install

P.S. Posting answer so that it will help other in future.

Manwal
  • 23,450
  • 12
  • 63
  • 93
1

Today, I lost a lot of time to solve this problem

Because libv8 is the interface for the V8 engine used by therubyracer, you may need to use libv8, even if you have V8 installed already.

from gihub


That's what helped me
if you use bundler
bundle config build.libv8 --with-system-v8
if you use rubygems
gem install libv8 -- --with-system-v8
and this

Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103
1

I had the same issue when I upgraded from OS X Mountain Lion to OS X Mavericks.

I followed these steps:

  1. brew install v8
  2. gem install libv8 -v '3.16.14.3' -- --with-system-v8
  3. gem install therubyracer -v '0.12.3' --source 'https://rubygems.org/' this may produce an error, don't worry if it does
  4. bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
  5. 'bundle install' - in my case this was not needed, but it may be in your case
0

Simply doing this solve my problem:

Gemfile

gem 'therubyracer'

And in

Terminal

gem uninstall libv8 [mention version if required]
bundle install
przbadu
  • 5,769
  • 5
  • 42
  • 67
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 to get libv8 and therubyracer gem

assuming rbenv:

rbenv install 1.8.7-p375
rbenv rehash
rbenv global 1.8.7-p375
bundle install
nelsonenzo
  • 682
  • 5
  • 9
0

I changed my ruby version and it work in macos big sur.

  1. rvm list rubies
    • I was using 2.6.1, but needed 2.3.7
  2. rvm use 2.3.7
    • if it isn't installed, run rvm install 2.3.7 first

rvm basics here other helpful rvm commands

gkee
  • 61
  • 1
  • 2
0

brew install v8@3.15 wont work

Homebrew have already disabled v8@3.15 -> https://formulae.brew.sh/formula/v8@3.15

I have an easy solution, you can use this link to download the official v8 content https://github.com/v8/v8/archive/3.15.11.18.tar.gz

This content should be copied to usr/local/opt/

nit: you can rename the folder to v8@3.15.

You can run the following command after renaming the folder

bundle config build.therubyracer --with-v8-dir=/usr/local/opt/v8@3.15/

Hope this works, Happy Coding!!