[Ruby On Rails (RoR) FAQs] Ruby 2.4+ and pre Rails 4.2.8 stack level too deep (SystemStackError)

stack level too deep (SystemStackError)

In Ruby 2.4, there was a unification of integer types (i.e. Fixnum and Bignum are now the very same thing: Integer). This results on quite a few incompatibilities with existing gems which relied on the distinction of the classes.

1
2
$ bundle exec rails s
/Users/cloudolife/.rvm/gems/ruby-2.5.9@camp/gems/activesupport-4.2.5/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)

Older versions of ActiveSupport are among those which don’t like this unification and barf over it when trying to serialize data. As such, you have one of two options:

  • You can downgrade Ruby to a version earlier than 2.4, e.g. Ruby 2.3.x.

  • Or you could upgrade Rails to a newer version. Preferably, that could be Rails 5.x. There is also a patch in the 4.2-stable branch which was released with Rails 4.2.8, making it the first version of the Rails 4.2 series that officially supports Ruby 2.4. Earlier Rails versions are not compatible with Ruby 2.4.

Upgrade Rails

Install Rails 4.2.8, it’s compatible with Ruby v 2.4+

in the Gemfile:

1
gem 'rails', '4.2.8'

Then:

1
$ bundle update rails

Or run gem install.

1
$ gem install rails -v '4.2.8'

References

[1] Ruby 2.4 and Rails 4 stack level too deep (SystemStackError) - Stack Overflow - https://stackoverflow.com/questions/41504106/ruby-2-4-and-rails-4-stack-level-too-deep-systemstackerror/41504382