#ruby-on-rails #server
Вопрос:
В настоящее время у меня возникли небольшие проблемы с моим приложением rails. Rails выдает мне эту ошибку всякий раз, когда я это делаю rails server
(или любую другую rails ___
команду, если на то пошло):
/Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111:in initialize: wrong number of arguments (given 3, expected 2) (ArgumentError)
Я использую ruby 3.0.0 и rails 5.2.3.
Вот полная ошибка:
/Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:37:in `new'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:37:in `build'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:101:in `block in build'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:101:in `each'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:101:in `inject'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:101:in `build'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/engine.rb:510:in `block in app'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/engine.rb:506:in `synchronize'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/engine.rb:506:in `app'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/initializable.rb:32:in `run'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/application.rb:361:in `initialize!'
from /Users/giancarlo_benedetti/coding/test_project-1/config/environment.rb:5:in `<main>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
from config.ru:3:in `block in <main>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands/server/server_command.rb:27:in `app'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands/server/server_command.rb:51:in `start'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands/server/server_command.rb:147:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands/server/server_command.rb:142:in `perform'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/command/base.rb:69:in `perform'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/command.rb:46:in `invoke'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/railties-5.2.4.5/lib/rails/commands.rb:18:in `<main>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /Users/giancarlo_benedetti/coding/test_project-1/bin/rails:9:in `<top (required)>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
from /Users/giancarlo_benedetti/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
from <internal:/Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/Users/giancarlo_benedetti/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /Users/giancarlo_benedetti/coding/test_project-1/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Я действительно понятия не имею, откуда это берется. Похоже, это может быть проблема либо с RVM, моим файлом драгоценных камней, либо с чем-то еще.
Заранее спасибо.
Ответ №1:
Rails 5.x не работает с Ruby 3.0 (подробнее здесь). У вас есть два варианта:
- понизить рейтинг Ruby до 2,7
- или
- обновите рельсы до 6.