Install therubyracer gem on OSX 10.11 El Capitan
Asked Answered
C

10

28

bundle install fails with Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling

gem install therubyracer -v '0.12.1' fails with errors which appear to relate to compilation

Prior to this, libv8 gem was having problems but that is now installed thanks to following SO posts.

Guides for fixing rubyracer for Mavericks seem to not work, due to changes in El Capitan?

ln: /usr/bin/cpp: Operation not permitted 
Caution answered 2/11, 2015 at 10:41 Comment(0)
C
93
  1. Install xcode through app store
  2. Install 'command line tools' for xcode (xcode-select --install)
  3. If using rbenv, after installing ruby you needed rbenv rehash
  4. Assuming you have run gem install bundler and got errors, remove your mess:

    gem uninstall libv8
    gem uninstall therubyracer
    brew rm v8
    
  5. Install gcc4.2

    brew tap homebrew/dupes
    brew install apple-gcc42
    
  6. Install v8

    brew tap homebrew/versions
    brew install v8-315
    brew link --force v8-315
    
  7. Install gems

    gem install libv8 -- --with-system-v8
    gem install therubyracer
    

    if you get dyld: lazy symbol binding failed: Symbol not found, @rpbaltazar suggests an alternative:

    bundle config --local build.libv8 --with-cxx=/usr/local/bin/g++-4.2
    bundle install
    
Caution answered 2/11, 2015 at 10:41 Comment(12)
This solved the problem for me. After several other involved methods, I think the key difference with this answer was simply providing the "old" compiler (GCC). Thank you.Lactiferous
I only needed to do step #7.Cyclamate
there was great pain and then there was this answer. THANK YOU!Crescentic
I take it back.. now I'm getting a different error dyld: lazy symbol binding failed: Symbol not found: _ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1 Referenced from: /development/opensource/rails-loaded/vendor/ruby/2.1.0/extensions/x86_64-darwin-15/2.1.0-static/therubyracer-0.12.2/v8/init.bundle Expected in: flat namespaceCrescentic
This should contain why it works. Uninstall and Install it completely is not really a good answer at all.Emlyn
Trial and error after reading dozens of SO posts with suggestions. To the best of my knowledge: EXPLANATIONCaution
@Crescentic I'm facing the same problem. Did you manage to solve this?Olly
People with problems - is there anything special about your setup? Are you using a Hackintosh? I cannot reproduce I am sorry =( I think I read somewhere that dyld changes might not take effect until reboot, could you try reboot and I'll add it as a step if it works?Caution
I did work it out and I'm ashamed to say I can't remember how. I want to say it was all related to GCC version. I am kicking myself for not coming back here and updating you all. @ZeroCrescentic
@Caution my laptop was stock mac, brand new & el capitanCrescentic
Found the answer that worked for me!!! #33343659Crescentic
Great thanks, the realy helpful answer. One from thousands that helped.Carlyn
E
51

I still had issues with @xxjjnn's answer. The following answer from github resolved it. My current setup: El Capitan 10.11.4 and Xcode 7.3.

brew tap homebrew/versions
brew install v8-315

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install
Explosion answered 3/4, 2016 at 4:38 Comment(5)
Worked for on El Capitan 10.11.3Serving
Worked on OS X 10.11.4 w/ Ruby 2.3.0 and Rails 4.2.6 - ProcessJeanene
Worked for me on OS X 10.11.4 Ruby 2.3.0, Rails 4.2.6 too. I tried various other approaches, this is the only one which solved the 'therubyracer' compile issue for me after I upgraded to Ruby 2.3.0Mitis
"gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315" saved me time!Brilliant
Despite the fact that homebrew/versions doesn't do anything these days, this solution basically worked for my on Catalina with the following changes: I had to specify libv8 3.16.14.19 instead of 3.16.14.13; and --with-v8-dir=/usr/local/opt/[email protected] as opposed to without the @ sign. I was using Ruby 2.4.6 and Rails 4.2.11.1 on Catalina 10.15.2.Dysuria
B
11

The answer provided on therubyracer Github page worked for me:

brew tap homebrew/versions
brew install v8-315
brew link --force v8-315
gem install libv8 -- --with-system-v8
gem install therubyracer
Bayly answered 28/3, 2016 at 13:38 Comment(0)
R
5

I updated the gem therubyracer to 0.12.2, then I runned this commands in the rails repository:

$ brew install v8-315
$ bundle config --local build.libv8 --with-system-v8
You are replacing the current local value of build.libv8, which is currently nil
$ bundle config --local build.therubyracer --with-v8-dir=$(brew --prefix v8-315)
You are replacing the current local value of build.therubyracer, which is currently nil

and finally

bundle install
Reins answered 18/4, 2019 at 13:59 Comment(1)
This worked on Catalina macOS 10.15, but with 0.12.3Alegar
W
3

I know this question is specifically about installing therubyracer -v '0.12.1', but the solution really is to upgrade to '0.12.2'.

I've struggled with this on a few projects and always forget that. Then eventually I remember and it all works.

Be sure to clean out anything you've added to bundle config once you don’t need it with bundle config --delete build.libv8.

Here’s the thread on the gem repo about this: https://github.com/cowboyd/therubyracer/issues/398#issuecomment-238161167

Weil answered 14/8, 2016 at 20:43 Comment(0)
P
2

(Posting as a comment for readability purposes, but this should be an add-on to the original accepted answer)

After running the accepted answer, I was facing the error described in the comments.

The solution I found helpful for me was running the following

gem uninstall libv8
gem uninstall therubyracer
bundle config --local build.libv8 --with-cxx=/usr/local/bin/g++-4.2
bundle install

Please note that the initial steps of the accepted answer are necessary, namely installing the compiler.

Pigpen answered 23/3, 2016 at 10:27 Comment(2)
I've nuked the ruby version and followed these instructions exactly and still get the "dyld: lazy symbol binding failed: Symbol not found" error. Any more insight here @PigpenWeil
hey. in which version are you having the problem? the steps described worked for me in el capitan. unfortunately without facing the problem myself i find it hard to solve as a lot of this was done by trial and error.Pigpen
D
2

Actually, apple-gcc42 is removed from brew:

apple-gcc42 was deleted from homebrew/core in commit bcba321ea:

Instead, I've installed [email protected] So, following xxjjnn answer, instead of 5 just run:

brew install [email protected]
Discant answered 2/1, 2019 at 14:15 Comment(0)
B
1

First try to delete your Gemfile.lock and run bundle install again. Gemfile.lock will be created again.

This will work for most cases on El Capitan.

Without that it will just install the same versions mentioned in Gemfile.lock. If you delete this file, bundle install will fetch newest versions of your gems.

Benedetto answered 3/5, 2016 at 5:35 Comment(0)
C
0

If none of the above works for you, follow this guys advice. Uninstalling everything related and upgrading gcc fixed it for me.

Gem install therubyracer -v '0.11.4'?

Crescentic answered 24/3, 2016 at 20:23 Comment(0)
M
0

If you can switch to mini racer, installing it or updating it worked for me similar to this post

How to fix libv8 bad version error

TL;DR bundle update mini_racer

Maurist answered 2/12, 2021 at 13:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.