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

12,595

Solution 1

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

Solution 2

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.

Solution 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.

Solution 4

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.

Solution 5

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
Share:
12,595
Amir
Author by

Amir

JavaScript during the day. Everything else not during the day,

Updated on July 01, 2022

Comments

  • Amir
    Amir almost 2 years

    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?