首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ruby2.4和Rails 4堆栈级太深(SystemStackError)

Ruby2.4和Rails 4堆栈级太深(SystemStackError)
EN

Stack Overflow用户
提问于 2017-01-06 18:53:33
回答 3查看 41.1K关注 0票数 71

我尝试在Rails 4.0.8中运行新创建的项目,但收到错误消息:

代码语言:javascript
复制
    rails s
=> Booting WEBrick
=> Rails 4.0.8 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
Exiting
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:124:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
     ... 5532 levels...
    from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `tap'
    from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Ruby版本:

代码语言:javascript
复制
Rails 4.0.8

我的Gemefile:

代码语言:javascript
复制
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.8'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'json', github: 'flori/json', branch: 'v1.8'
group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

我尝试重新安装rails,因为在我的机器上安装了5.0 Rails之前。

本地宝石:

代码语言:javascript
复制
*** LOCAL GEMS ***

autoprefixer-rails (6.6.0)
coffee-rails (4.2.1, 4.0.1)
font-awesome-rails (4.7.0.1)
jquery-atwho-rails (1.3.2)
jquery-rails (4.2.2, 3.1.4)
rails (4.0.8, 4.0.0)
rails-dom-testing (2.0.2)
rails-html-sanitizer (1.0.3)
rails_12factor (0.0.3)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
sass-rails (5.0.6, 4.0.5)
sprockets-rails (3.2.0, 2.3.3, 2.0.1)

Meybe unistall: ruby和rails可以解决这个问题,但我不想这么做。我希望同时安装两个版本的rails,例如: rails 4和rails 5。这样的配置可行吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-01-06 19:08:23

在Ruby2.4中,统一了整数类型(即FixnumBignum现在是完全相同的:Integer)。这导致了相当多的与现有gem的不兼容,这些gem依赖于类的区别。

旧版本的ActiveSupport不喜欢这种统一,并且在尝试序列化数据时会对此感到厌烦。因此,您有以下两种选择之一:

Rails你可以把降级到2.4之前的版本,比如Ruby2.3.x.

  • ,或者你也可以把Rails升级到新版本。最好是Rails 5.x。与Rails 4.2.8一起发布的4.2 -稳定分支中也有一个补丁,使其成为正式支持Ruby2.4的Rails4.2系列的第一个版本。早期的Rails版本与Ruby2.4不兼容。
票数 136
EN

Stack Overflow用户

发布于 2017-05-02 13:37:04

我有同样的错误,但我不想升级到5.0,我的应用程序非常大,升级需要太多时间。我正在将Rails 4.1.7升级到支持Ruby 2.4Rails to 4.2.8 first Rails发行版:

在Gemfile中:

代码语言:javascript
复制
gem 'rails', '4.2.8'

然后:

代码语言:javascript
复制
bundle update rails
票数 45
EN

Stack Overflow用户

发布于 2017-01-06 19:08:44

至于这个错误,您运行的是刚刚发布的Ruby2.4,Rails和ActiveSupport (特别是它们的老版本)很可能还不支持它。

Rails指南指出您的Rails版本(4.0.8)首选This 2.0。

你可以通过升级你的Rails安装(gem 'rails', '5.0')或者使用版本管理器(例如$ rvm install 2.3.0; rvm use 2.3.0)降级到老版本来修复这个错误。

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41504106

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档