Search code examples
ruby-on-railsrubyherokugit-push

Update a Ruby on Rails app to work on newer Heroku Stack


I had worked over a year ago on a Ruby on Rails app that was set up initially to run on Heroku Stack 18 which I have now learned is depricated. I am trying to get that app working again on a newer stack but whenever I try to push up it tells me that the Ruby version (2.5.1) does not exist. I would love some insight on how to upgrade my Ruby/Rails versions so that I don't need to make the project from scratch again. Thanks in advance.

When running the push to the heroku remote I get the following output:

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

Solution

  • Looks like the oldest supported Ruby on Heroku is version 3.0.6 on Heroku-20, and you are on Rails 5.2. According to this compatibility table, you should reach Rails 6.1 for Ruby 3.

    For Rails upgrades, it's best to follow the official guide, doing it version-by-version and ensuring the correct behaviour.

    Same for Ruby, I recommend this guide, checking out what has changed from one version to another and modifying your code if necessary.