簡體   English   中英

Ruby 2.4 和 Rails 4 堆棧級別太深 (SystemStackError)

[英]Ruby 2.4 and Rails 4 stack level too deep (SystemStackError)

我正在嘗試在 Rails 4.0.8 中運行新創建的項目,但收到錯誤消息:

    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>'

紅寶石版本:

Rails 4.0.8

我的 Gemefile:

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 之前。

本地寶石:

*** 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 會解決這個問題,但我不想那樣做。 Beasically 我想要安裝兩個版本的導軌,例如:導軌 4 和導軌 5。 這種配置可以嗎?

在 Ruby 2.4 中,統一了整數類型(即FixnumBignum現在完全相同: Integer )。 這導致了與依賴於類別區別的現有 gem 的相當多的不兼容。

舊版本的 ActiveSupport 是那些不喜歡這種統一並在嘗試序列化數據時對它嗤之以鼻的人之一。 因此,您有以下兩種選擇之一:

  • 您可以將 Ruby 降級到 2.4 之前的版本,例如 Ruby 2.3.x。
  • 或者您可以將 Rails 升級到更新的版本。 最好是 Rails 5.x。 Rails 4.2.8發布的 4.2-stable 分支中還有一個補丁,使其成為正式支持 Ruby 2.4 的 Rails 4.2 系列的第一個版本。 較早的 Rails 版本與 Ruby 2.4 不兼容。

我有同樣的錯誤,但我不想升級到 5.0,我的應用程序非常大,升級需要太多時間。 我正在將Rails 4.1.7升級到Rails to 4.2.8第一個支持Ruby 2.4 Rails 版本:

在 Gemfile 中:

gem 'rails', '4.2.8'

然后:

bundle update rails

關於錯誤,您正在運行剛剛發布的 Ruby 2.4,Rails 和 ActiveSupport(尤其是這些的舊版本)很可能還不支持。

Rails 指南指出您的 Rails 版本 (4.0.8) 更喜歡 Ruby 2.0。

您可以通過升級 Rails 安裝( gem 'rails', '5.0' )或使用版本管理器降級到舊版本的 Ruby 來修復錯誤(例如$ rvm install 2.3.0; rvm use 2.3.0 )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM