在 static.rb 文件中的 rails 上启动 ruby 的问题
Issue launching ruby on rails in static.rb file
我正在尝试在 heroku 上的 rails 应用程序上部署一个 ruby,所以我将我的 ruby 版本更新为 ruby 3.0.0 并进行了捆绑更新/捆绑安装但它说我无法推送甚至 运行 本地开发服务器。
=> Booting Puma
=> Rails 5.1.7 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/static.rb:109:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35:in `new'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35:in `build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `block in build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `each'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `inject'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:508:in `block in app'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:504:in `synchronize'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:504:in `app'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/application/finisher.rb:45:in `block in <module:Finisher>'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:30:in `run'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:59:in `block in run_initializers'
from /Users/username/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /Users/username/.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/username/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
...
有问题的 static.rb 文件:
module ActionDispatch
...
class Static
def initialize(app, path, index: "index", headers: {})
@app = app
@file_handler = FileHandler.new(path, index: index, headers: headers)
end
def call(env)
req = Rack::Request.new env
if req.get? || req.head?
path = req.path_info.chomp("/".freeze)
if match = @file_handler.match?(path)
req.path_info = match
return @file_handler.serve(req)
end
end
@app.call(req.env)
end
end
end
ruby 版本:ruby 3.0.0p0
rails版本:Rails5.1.7
gem版本:3.2.12
你能帮帮我吗?
ruby 2.7+ support 仅从 rails 6 开始可用,因此您需要降级 ruby 或升级 rails
我正在尝试在 heroku 上的 rails 应用程序上部署一个 ruby,所以我将我的 ruby 版本更新为 ruby 3.0.0 并进行了捆绑更新/捆绑安装但它说我无法推送甚至 运行 本地开发服务器。
=> Booting Puma
=> Rails 5.1.7 application starting in development
=> Run `rails server -h` for more startup options
Exiting
/Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/static.rb:109:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35:in `new'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35:in `build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `block in build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `each'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `inject'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:99:in `build'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:508:in `block in app'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:504:in `synchronize'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/engine.rb:504:in `app'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/application/finisher.rb:45:in `block in <module:Finisher>'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:30:in `run'
from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-5.1.7/lib/rails/initializable.rb:59:in `block in run_initializers'
from /Users/username/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /Users/username/.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/username/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
...
有问题的 static.rb 文件:
module ActionDispatch
...
class Static
def initialize(app, path, index: "index", headers: {})
@app = app
@file_handler = FileHandler.new(path, index: index, headers: headers)
end
def call(env)
req = Rack::Request.new env
if req.get? || req.head?
path = req.path_info.chomp("/".freeze)
if match = @file_handler.match?(path)
req.path_info = match
return @file_handler.serve(req)
end
end
@app.call(req.env)
end
end
end
ruby 版本:ruby 3.0.0p0
rails版本:Rails5.1.7
gem版本:3.2.12
你能帮帮我吗?
ruby 2.7+ support 仅从 rails 6 开始可用,因此您需要降级 ruby 或升级 rails