一年多前,我曾在一个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
1条答案
按热度按时间yqyhoc1h1#
看起来Heroku上支持的最早的Ruby是Heroku-20上的3.0.6版本,而你在Rails 5.2上。根据这个compatibility table,你应该达到Ruby 3的Rails 6.1。
对于Rails升级,最好遵循the official guide,逐版本执行并确保正确的行为。
对于Ruby也是一样,我推荐this guide,检查从一个版本到另一个版本的变化,并在必要时修改代码。