首页 > 解决方案 > 如何修复“警告:常量 ::Fixnum 已弃用”错误

问题描述

当我尝试从 RubyMine IDE 运行我的 rails 服务器时,我收到错误消息:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback

我目前正在使用 Rails 4.2.7.1 运行 Ruby 2.5.5p157。为了运行 Web 应用程序,我应该怎么做?非常感谢您的帮助!


尝试运行网站时的完整日志:

C:\Ruby25-x64\bin\ruby.exe "C:/Users/Sam/Desktop/Takai/Website/bin/rails" server -b 127.0.0.1 -p 3000 -e development -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback
 (most recent call last):
C:/Users/Sam/Desktop/Takai/Website/bin/rails: stack level too deep (SystemStackError)

Process finished with exit code 1

标签: ruby-on-railsrubyrubygems

解决方案


您正在使用旧版本的 Rails 和新版本的 Ruby,Rails 想要使用Fixnum新版本的 Ruby 中不再存在的东西 ( )。

你有两个选择:

  1. 使用旧版本的 Rails 支持的 Ruby 版本。根据这个列表, Ruby 2.4 应该适合你。
  2. 将您的 Rails 应用程序更新为支持 Ruby 2.5 的更新版本的 Rails。Rails 5.1 似乎是第一个正式支持 Ruby 2.5 的 Rails 版本

第一个选项可能要容易得多。但我仍然建议更新您的 Rails 版本,因为您的 Rails 版本未维护,不会再获得任何更新或安全性。


推荐阅读