bundlerosx-elcapitantherubyracer

Install therubyracer gem on OSX 10.11 El Capitan


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 

Solution

    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