Amir
Amir

Reputation: 2267

Error when running "bundle install" on mac - therubyracer failing to install

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?

Upvotes: 7

Views: 16874

Answers (10)

Shabreesh Nair
Shabreesh Nair

Reputation: 21

brew install [email protected] wont work

Homebrew have already disabled [email protected] -> https://formulae.brew.sh/formula/[email protected]

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 [email protected].

You can run the following command after renaming the folder

bundle config build.therubyracer --with-v8-dir=/usr/local/opt/[email protected]/

Hope this works, Happy Coding!!

Upvotes: 0

gkee
gkee

Reputation: 111

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

Upvotes: 0

Feuda
Feuda

Reputation: 2365

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

$ brew install [email protected]
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
$ bundle install

@3.15 could be replaced with any other versions.

Upvotes: 10

designernaruka
designernaruka

Reputation: 13

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 [email protected])
  5. 'bundle install' - in my case this was not needed, but it may be in your case

Upvotes: 1

Manwal
Manwal

Reputation: 23816

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.

Upvotes: 3

nelsonenzo
nelsonenzo

Reputation: 680

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

Upvotes: 0

przbadu
przbadu

Reputation: 6049

Simply doing this solve my problem:

Gemfile

gem 'therubyracer'

And in

Terminal

gem uninstall libv8 [mention version if required]
bundle install

Upvotes: 0

nil
nil

Reputation: 2278

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.

Upvotes: 3

Roman Kiselenko
Roman Kiselenko

Reputation: 44370

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

Upvotes: 1

Leo Gallucci
Leo Gallucci

Reputation: 16722

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

Upvotes: 13

Related Questions