我尝试在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>'Ruby版本:
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可以解决这个问题,但我不想这么做。我希望同时安装两个版本的rails,例如: rails 4和rails 5。这样的配置可行吗?
发布于 2017-01-06 19:08:23
在Ruby2.4中,统一了整数类型(即Fixnum和Bignum现在是完全相同的:Integer)。这导致了相当多的与现有gem的不兼容,这些gem依赖于类的区别。
旧版本的ActiveSupport不喜欢这种统一,并且在尝试序列化数据时会对此感到厌烦。因此,您有以下两种选择之一:
Rails你可以把降级到2.4之前的版本,比如Ruby2.3.x.
发布于 2017-05-02 13:37:04
我有同样的错误,但我不想升级到5.0,我的应用程序非常大,升级需要太多时间。我正在将Rails 4.1.7升级到支持Ruby 2.4的Rails to 4.2.8 first Rails发行版:
在Gemfile中:
gem 'rails', '4.2.8'然后:
bundle update rails发布于 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)降级到老版本来修复这个错误。
https://stackoverflow.com/questions/41504106
复制相似问题