使用 libv8 & devise & therubyracer 将应用程序升级到 rails 4.2.1

Issue upgrading application to rails 4.2.1 with libv8 & devise & therubyracer

我的应用程序在使用以下 gemfile 时一切正常:

source 'https://rubygems.org'


#ruby version
ruby "2.1.5"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.10'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

#add bootstrap css
gem "twitter-bootstrap-rails"
gem "therubyracer"
gem "less-rails"

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

#Add paperclip for image uploading - requires imagemagick - need rmagick for heroku?
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
gem 'rmagick'
#aws-sdk for s3 capability production only
gem 'aws-sdk', group: :production

gem "rake", '10.4.2'

#Adding geoip for our lookup location services
gem 'geoip', '~> 1.4.0'

#Adding a exception notifier for debugging on heroku
gem 'exception_notification'

#annotate model game so models get details of the database contents added as comments to the top of their files
gem 'annotate', '~> 2.6.5'

#for oauth authentication with Stripe api
gem 'omniauth-stripe-connect'

#for stripe checkout
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'

#for user management
gem 'devise'
#for devise facebook omni auth
gem 'omniauth-facebook'

#for storing my custom settings
gem 'rails_config'

#HTTParty for easily consuming external web services in the ruby app - used for GDistance class in services
gem 'httparty'

#i need the latest version of fontawesome - the one in bootstrap is too old!
gem "font-awesome-rails"

#google analytics - for production only
gem 'rack-google_analytics', group: :production

#ahoy is for on site analytics - trying it out
gem 'ahoy_matey'

#using socialization gem for user follows
gem 'socialization'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

我想更新我的应用程序以使用 Rails 4.2.1,所以我在我的 gemfile 中更新了这一行:

gem 'rails', '4.2.1'

当我然后 运行 捆绑包更新时,我收到以下错误:

Using less 2.6.0
Using less-rails 2.7.0 (was 2.6.0)

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

    /Users/andyarmstrong/.rbenv/versions/2.1.5/bin/ruby -r ./siteconf20150701-17291-17o68o1.rb 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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
make: *** [x64.release] Error 2
/Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:35:in `each'
    from /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
  LIBTOOL-STATIC /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/libpreparser_lib.a
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser/preparser/preparser-process.o
  LINK(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/preparser
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o

extconf failed, exit code 1

Gem files will remain installed in /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8 for inspection.
Results logged to /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/libv8-3.16.14.8/gem_make.out
An error occurred while installing libv8 (3.16.14.8), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.8'` succeeds before bundling.

然后我尝试了错误提示的命令:

gem install libv8 -v '3.16.14.8'

此命令失败并出现此错误:

Andys-MacBook-Pro:andyhelloworldruby andyarmstrong$ gem install libv8 -v '3.16.14.8'
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
    ERROR: Failed to build gem native extension.

    /Users/andyarmstrong/.rbenv/versions/2.1.5/bin/ruby -r ./siteconf20150701-18322-ri2u8p.rb 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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
make: *** [x64.release] Error 2
/Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:35:in `each'
    from /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
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/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
  LIBTOOL-STATIC /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/libpreparser_lib.a
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/preparser/preparser/preparser-process.o
  LINK(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/preparser
  CXX(target) /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o

extconf failed, exit code 1

Gem files will remain installed in /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.8 for inspection.
Results logged to /Users/andyarmstrong/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/libv8-3.16.14.8/gem_make.out

做一些搜索我尝试了以下命令:

gem install libv8 -v '3.16.14.8' -- --with-system-v8 - 成功了,但是当我再次尝试捆绑更新时,therubyracer 无法解析 v8,因为我认为系统没有安装 v8。

我该如何解决这个 libv8 问题?

问题是因为 libv8 源中的问题:https://github.com/cowboyd/libv8/issues/174

它已通过安装“3.16.14.7”修复,如下所示:

gem install libv8 -v '3.16.14.7' 

然后就通过了,所以将其添加到 gemfile 中:

gem 'libv8', '3.16.14.7'