Ruby
Rails

Rubyを2.4に上げたら4.2系列のRailsが stack level too deep で死ぬ時の対処法

More than 1 year has passed since last update.

Ruby2.4 が出たので軽率にアップデートするとこんなエラーが出ました。

/Users/ironsand/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/Users/ironsand/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
/Users/ironsand/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/business_time-0.7.6/lib/business_time/core_ext/fixnum.rb:6: warning: constant ::Fixnum is deprecated
/Users/ironsand/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:124:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)

いくつかの警告とstack level too deepエラーがactive_supportnumericで出てますね。

対策

Railsの4.2系の最新の4.2.7.1でもまだ対応できてないようなので、githubから最新の安定版ブランチをとってきましょう。

Gemfile
gem 'rails', github: 'rails/rails', branch: '4-2-stable'

参考

https://github.com/rails/rails/pull/25161