Ruby on Rails - rails服务器在启动后立即退出(SystemStackError) [英] Ruby on Rails - rails server exits immediately after starting (SystemStackError)

查看:531
本文介绍了Ruby on Rails - rails服务器在启动后立即退出(SystemStackError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在C盘中使用Windows 10 bash设置了Ruby on Rails。我用rbenv来设置它,并将我的ruby版本更新为2.4.0。然后,我更新了Rails版本到4.2.6并运行了软件包更新来更新我的宝石,并且我运行了rails服务器,但它不启动服务器。相反,它会立即退出服务器,并显示以下错误消息:


/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:警告:常量:: Fixnum已被弃用
/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已弃用
/ home / yschang / .rbenv / versions / 2.4.0 / lib / ruby​​ / gems / 2.4.0 / gems / fspath-3.0.1 / lib / fspath.rb:154:警告:常量:: Fixnum已被弃用
=>引导瘦
=> Rails 4.2.7.1应用程序从 http:// localhost:3000 开发开始
=>为更多启动选项运行 rails server -h
=> Ctrl-C关闭服务器
/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:警告:常量:: Fixnum已被弃用
/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已弃用
/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:警告:常量:: Bignum已弃用
正在退出
/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:在< class:Numeric>中: block(2 levels):stack level too(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:in block(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:在块(2级)中n< class:Numeric>'来自/home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext的
/home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4中的
中的/numeric/conversions.rb:131:in
块(2个级别) .0 / gems / activesupport-4.2.7.1 / lib / active_support / core_ext / numeric / conversions.rb:131:<< class:Numeric>'
from block(2 levels) /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'
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:在< class:Numeric>从/home/yschang/.rbenv/versions/2.4.0开始的块(2级) /lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:131:in 从/home/yschang/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/获取'
中的块(2层)在< class:Numeric>'
... 5011 levels ...
from / home / yschang / .rbenv /版本/ 2.4.0 / lib中/红宝石/宝石/ 2.4.0 /宝石/ railties-4.2.7.1 / lib目录/导轨/命令/ commands_tasks.rb:39:在
run_command! $ / b / b 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)>'bin / rails中的
:4:in
require'
from bin / rails:4:in` p>

非常感谢任何帮助。在Ruby 2.3.x或更低版本中,有一个基类Integer,你不直接实例化或寻址。相反,你用有限的精度解决假想的快速Fixnum或者可以处理非常大数字的假定较慢的Bignum。在Ruby 2.4.0中,维护者创建了真正令人吃惊的决定是'贬低'Fixnum和Bignum,并将它们都转换为Integer。任何使用Fixnum或Bignum的代码都会收到警告。任何测试或其他代码反省例如 42 的类将得到答案整数而不是 Fixnum



这是一个很难处理现实世界代码的难题(例如a gem),它希望在Ruby 2.3.x或更早版本,或2.4.0或更新版本上运行。



Rails 4.2早于Ruby 2.4,我不知道它是否会完全兼容。我的猜测是,将系统的Ruby降级到2.3.3将清除你的问题。它肯定会摆脱所有警告,污染你的控制台,如果崩溃仍然发生,给予更好的机会看到相关信息,从而揭露根源。


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.

解决方案

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.

这篇关于Ruby on Rails - rails服务器在启动后立即退出(SystemStackError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆