Ruby on Rails - rails server exits immediately after starting (SystemStackError)

对着背影说爱祢 提交于 2019-12-08 04:45:10

问题


I have set up Ruby on Rails using Windows 10 bash in C drive. I've used rbenv to set it up and updated my ruby version to 2.4.0. Then, I updated the rails version to 4.2.6 and ran bundle update to update my gem, and I ran rails server, but it's not starting the server. Instead, it exits the server immediately and it shows me the following error:

/home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thread_safe-0.3.5/lib/thread_safe/cache.rb:155: warning: constant ::Fixnum is deprecated /home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thread_safe-0.3.5/lib/thread_safe/cache.rb:155: warning: constant ::Fixnum is deprecated /home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/fspath-3.0.1/lib/fspath.rb:154: warning: constant ::Fixnum is deprecated => Booting Thin => Rails 4.2.7.1 application starting in development on http://localhost:3000 => Run rails server -h for more startup options => Ctrl-C to shutdown server /home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thread_safe-0.3.5/lib/thread_safe/cache.rb:155: warning: constant ::Fixnum is deprecated /home/yschang/.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 /home/yschang/.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 Exiting /home/yschang/.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) from /home/yschang/.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:131:inblock (2 levels) in ' from /home/yschang/.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:131:in block (2 levels) in <class:Numeric>' from /home/yschang/.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:131:inblock (2 levels) in ' from /home/yschang/.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:131:in block (2 levels) in <class:Numeric>' from /home/yschang/.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:131:inblock (2 levels) in ' from /home/yschang/.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:131:in block (2 levels) in <class:Numeric>' from /home/yschang/.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:131:inblock (2 levels) in ' from /home/yschang/.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:131:in block (2 levels) in <class:Numeric>' ... 5011 levels... from /home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:inrun_command!' from /home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in <top (required)>' from bin/rails:4:inrequire' from bin/rails:4:in `'

Any help is greatly appreciated. Thanks.


回答1:


In Ruby 2.3.x or earlier, there's a base class Integer which you don't instantiate or address directly. Instead, you address the supposed-fast Fixnum with limited precision or the supposed-slower Bignum which can handle very large numbers.

In Ruby 2.4.0, the maintainers made the genuinely astonishing decision to 'deprecate' Fixnum and Bignum, rolling them both into Integer. Any code using Fixnum or Bignum will get a warning. Any tests or other code introspecting on for example the class of 42 will get the answer Integer instead of Fixnum.

This is a very, very difficult change to handle in real world code (e.g. a gem) that wants to run on both Ruby 2.3.x or earlier, or 2.4.0 or later.

Rails 4.2 predates Ruby 2.4 and I don't know if it is fully compatible. My guess is that downgrading your system's Ruby to 2.3.3 will clear your issues. It'll certainly get rid of all the warnings polluting your console and, if the crash still happens, give a better chance of seeing a relevant message giving away the root cause.



来源:https://stackoverflow.com/questions/41903202/ruby-on-rails-rails-server-exits-immediately-after-starting-systemstackerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!