提问人:PresleyThe3 提问时间:8/24/2023 更新时间:8/24/2023 访问量:50
更新 Ruby on Rails 应用程序以在更新的 Heroku 堆栈上运行
Update a Ruby on Rails app to work on newer Heroku Stack
问:
一年多前,我曾开发过一个 Ruby on Rails 应用程序,该应用程序最初是为在 Heroku Stack 18 上运行而设置的,我现在了解到它已被废弃。我正在尝试让该应用程序在较新的堆栈上再次运行,但每当我尝试向上推送时,它都会告诉我 Ruby 版本 (2.5.1) 不存在。我希望能了解如何升级我的 Ruby/Rails 版本,这样我就不需要再次从头开始制作项目。提前致谢。
当运行推送到 heroku 遥控器时,我得到以下输出:
Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: ArgumentError: wrong number of arguments (given 3, expected 2)
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/static.rb:111:in `initialize'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:37:in `new'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:37:in `build'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:101:in `block in build'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:101:in `each'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:101:in `inject'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/stack.rb:101:in `build'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/engine.rb:510:in `block in app'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/engine.rb:506:in `synchronize'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/engine.rb:506:in `app'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/initializable.rb:32:in `instance_exec'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/initializable.rb:32:in `run'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/initializable.rb:61:in `block in run_initializers'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/initializable.rb:60:in `run_initializers'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/application.rb:361:in `initialize!'
remote: /tmp/build_fbf58a0c/config/environment.rb:5:in `<main>'
remote: <internal:/tmp/build_fbf58a0c/vendor/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
remote: <internal:/tmp/build_fbf58a0c/vendor/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/application.rb:337:in `require_environment!'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/railties-5.2.8.1/lib/rails/application.rb:520:in `block in run_tasks_blocks'
remote: /tmp/build_fbf58a0c/vendor/bundle/ruby/3.2.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
remote: Tasks: TOP => environment
remote: (See full trace by running task with --trace)
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
答:
0赞
David
8/24/2023
#1
看起来 Heroku 上支持的最旧的 Ruby 是 Heroku-20 上的 3.0.6 版本,而您使用的是 Rails 5.2。根据这个兼容性表,你应该达到 Ruby 3 的 Rails 6.1。
对于 Rails 升级,最好遵循官方指南,逐个版本进行升级,并确保正确的行为。
Ruby 也是如此,我推荐本指南,检查从一个版本到另一个版本的变化,并在必要时修改您的代码。
评论
0赞
PresleyThe3
8/25/2023
非常感谢,我没有意识到我必须将它们结合起来,我以为一个会级联来修复另一个。现在我只需要弄清楚为什么我的应用程序没有显示,尽管推送成功并且日志中没有错误。
0赞
David
8/25/2023
@PresleyThe3很高兴听到它。它在本地工作吗?我遇到了类似的问题,除了在生产/ Docker中,一切正常,日志也是空的。缺少的部分是密钥。
评论