我试图将我的网站从Ruby 2.7升级到Ruby 3.1。我更新了Gemfile以指向新版本的Ruby,运行bundle install
,并运行rails test
来运行我的测试套件。我立即得到一个错误:wrong number of arguments (given 2, expected 1) (ArgumentError)
。当我尝试运行rails console
时也会发生同样的事情;我甚至无法进入控制台命令提示符。
我不知道该怎么调试,因为它在初始化的时候出错了,看起来它在carrierwave-aws初始化的时候失败了,但是我用的是最新版本的gem。
Gemfile:
source 'https://rubygems.org'
ruby '~> 3.1.4'
gem 'rails', '~> 5.2.8'
gem 'faker', '~> 1.6.6'
gem 'will_paginate', '~> 3.3.1'
gem 'bootstrap-will_paginate', '~> 1.0.0'
gem 'bootstrap-sass', '~> 3.4.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '~> 4.2'
gem 'jquery-rails', '~> 4.4.0'
gem 'turbolinks', '~> 5.2.0'
gem 'jbuilder', '~> 2.8'
gem 'sdoc', '0.4.0', group: :doc
gem 'devise', '~> 4.7.1'
gem 'pg', '~> 1.4.6'
gem 'figaro', '~> 1.1.1'
gem 'font-awesome-sass', '~> 4.5.0'
gem 'morrisjs-rails', '~> 0.5.1'
gem 'raphael-rails', '~> 2.1.2'
gem 'redcarpet', '~> 3.3.4'
gem 'active_record_union', '~> 1.3.0'
gem "mini_magick", '~> 4.12.0'
gem 'carrierwave', '~> 2.2.3'
gem 'carrierwave-aws', '~> 1.5.0'
gem 'business_time', '~> 0.9.3'
gem 'rails-controller-testing', '~> 1.0.1'
gem 'prawn', '~> 2.4.0'
gem 'responders', '~> 2.4.1'
gem 'barby', '~> 0.6.6'
gem 'rqrcode', '~> 0.10.1'
gem 'combine_pdf', '~> 1.0.15'
group :development, :test do
#gem 'sqlite3', '~> 1.3.13'
gem 'byebug', '~> 11.1.3'
gem 'spring', '1.1.3'
end
group :development do
gem 'web-console', '~> 3.3.1'
gem 'rack-mini-profiler'
end
group :test do
gem 'minitest-reporters', '~> 1.1.11'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '~> 2.4.6'
gem 'pdf-reader', '~> 2.2.0'
end
group :production do
gem 'seed_dump', '3.2.4'
end
错误:
$ rails console
/home/vagrant/.rvm/rubies/ruby-3.1.4/bin/ruby: warning: shebang line ending with \r may cause problems
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/home/vagrant/.rvm/gems/ruby-3.1.4/gems/json-1.8.6/lib/json/common.rb:155:in `initialize': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/json-1.8.6/lib/json/common.rb:155:in `new'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/json-1.8.6/lib/json/common.rb:155:in `parse'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath/lexer.rb:323:in `requires_wrapping?'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath/lexer.rb:328:in `<class:Lexer>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath/lexer.rb:7:in `<module:JMESPath>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath/lexer.rb:5:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath.rb:9:in `<module:JMESPath>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/jmespath-1.6.2/lib/jmespath.rb:6:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/aws-sdk-core-3.171.0/lib/aws-sdk-core.rb:5:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/aws-sdk-kms-1.63.0/lib/aws-sdk-kms.rb:11:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/aws-sdk-s3-1.121.0/lib/aws-sdk-s3.rb:11:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/carrierwave-aws-1.5.0/lib/carrierwave/storage/aws.rb:3:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/carrierwave-aws-1.5.0/lib/carrierwave-aws.rb:5:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:60:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:55:in `each'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:55:in `block in require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:44:in `each'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler/runtime.rb:44:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/bundler-2.4.12/lib/bundler.rb:196:in `require'
from /vagrant/config/application.rb:7:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/command/actions.rb:22:in `require'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/command/actions.rb:22:in `require_application!'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/command/actions.rb:14:in `require_application_and_environment!'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/commands/console/console_command.rb:95:in `perform'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/command/base.rb:69:in `perform'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/command.rb:46:in `invoke'
from /home/vagrant/.rvm/gems/ruby-3.1.4/gems/railties-5.2.8.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
1条答案
按热度按时间o2rvlv0m1#
正如tadman所建议的,问题源于Ruby和Rails版本之间的不兼容,升级到rails6解决了这个问题。