Problems with Yosemite, therubyracer, and V8

So today I went to run my website after having added the rubyracer gem to my Gemfile like so.

    gem 'therubyracer'
  

After running bundle install I got the following error.

    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

        /Users/aasierra/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
    creating Makefile
    Compiling v8 for x64
    Using python 2.7.6
    Using compiler: /usr/bin/c++ (clang version 6.1.0)
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o has no symbols
    In file included from ../src/accessors.cc:28:
    In file included from ../src/v8.h:60:
    In file included from ../src/objects-inl.h:38:
    In file included from ../src/elements.h:33:
    In file included from ../src/heap.h:35:
    In file included from ../src/incremental-marking.h:33:
    In file included from ../src/mark-compact.h:32:
    ../src/spaces.h:896:26: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
      bool exists() { return this != NULL && code_range_ != NULL; }
                             ^~~~    ~~~~
    ../src/spaces.h:898:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
        if (this == NULL || code_range_ == NULL) return false;
            ^~~~    ~~~~
    2 errors generated.
    make[1]: *** [/Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
    make: *** [x64.release] Error 2
    /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `each'
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `verify_installation!'
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:26:in `install!'
    	from extconf.rb:7:in `
' GYP_GENERATORS=make \ build/gyp/gyp --generator-output="out" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ -Dv8_target_arch=x64 \ -S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o LIBTOOL-STATIC /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/libpreparser_lib.a CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser/preparser/preparser-process.o LINK(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/preparser CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o extconf failed, exit code 1 Gem files will remain installed in /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11 for inspection. Results logged to /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/libv8-3.16.14.11/gem_make.out An error occurred while installing libv8 (3.16.14.11), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.11'` succeeds before bundling.

Which then led me to try the command below and versioned variations.

    gem install libv8 -v '3.16.14.11'
  

These all just lead to the below error.

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

        /Users/aasierra/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
    creating Makefile
    Compiling v8 for x64
    Using python 2.7.6
    Using compiler: /usr/bin/c++ (clang version 6.1.0)
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o has no symbols
    In file included from ../src/accessors.cc:28:
    In file included from ../src/v8.h:60:
    In file included from ../src/objects-inl.h:38:
    In file included from ../src/elements.h:33:
    In file included from ../src/heap.h:35:
    In file included from ../src/incremental-marking.h:33:
    In file included from ../src/mark-compact.h:32:
    ../src/spaces.h:896:26: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true [-Werror,-Wtautological-undefined-compare]
      bool exists() { return this != NULL && code_range_ != NULL; }
                             ^~~~    ~~~~
    ../src/spaces.h:898:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
        if (this == NULL || code_range_ == NULL) return false;
            ^~~~    ~~~~
    2 errors generated.
    make[1]: *** [/Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
    make: *** [x64.release] Error 2
    /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `each'
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:35:in `verify_installation!'
    	from /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/ext/libv8/location.rb:26:in `install!'
    	from extconf.rb:7:in `
' GYP_GENERATORS=make \ build/gyp/gyp --generator-output="out" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ -Dv8_target_arch=x64 \ -S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o LIBTOOL-STATIC /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/libpreparser_lib.a CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/preparser/preparser/preparser-process.o LINK(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/preparser CXX(target) /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o extconf failed, exit code 1 Gem files will remain installed in /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/gems/libv8-3.16.14.11 for inspection. Results logged to /Users/aasierra/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/libv8-3.16.14.11/gem_make.out

TL;DR

To fix I had to install Ruby 2.2.2

    rvm install 2.2.2
    gem install rails
    bundle install
  

Details

After doing some research I found that this was due to a problem with having Yosemite on my computer and trying to add this gem, and actually there is an open PR here for this exact problem. But moving on I attempted to download libv8 to build and install it myself. To no avail though.

So after that failure I went online to research (once again) and I found suggestions online to simply uninstall the current version of ruby and reinstall it. Again no luck (using RVM). What I did end up finding out though, which I already knew but did not care, was that 1.9.3-p547 of Ruby was no longer supported.

Learning what I did above I simply decided to upgrade to Ruby 2.2.2. After that installed I could simply install rails and update my bundle using the commands seen in the TL;DR section and I was good to go and ready to get this website back up and running.

While I know this solution does not necessarily solve the problem, here is at least my story so hopefully others can try these steps or maybe just jump ship to the newest Ruby version like I did. If anything I would follow up on the ticket above and see if a fix comes in the future.