Upgrade to Ruby 3.2.1 and Rails 7.0.4.3
Channel: Stateless Code
Date: 2023-03-27

While we were working on our NerdDice RubyGem, new versions of Ruby (upgrading from 3.2.0 to 3.2.1) and Rails (upgrading from 7.0.4.2 to 7.0.4.3) came out. There were also 3 new Dependabot alerts related to Rack and Active Support. 

We were planning to do a full `bundle update` on the project. There was one problem the last time, where the debug gem wasn't properly registering its dependencies. Also we know that a new version of Devise is available, but we're going to deal with that upgrade in a separate story.

We start by modifying our .ruby-version file and Gemfile to indicate Ruby 3.2.1 instead of 3.2.0. In this case 3.2.1 is not currently installed on the system, so we install Ruby 3.2.1 using RVM and set it as the new default.

After that, we run `bundle update` to upgrade the bundle of Gems. This will update the version of Rails and Rack to clear our Dependabot alerts. 

After that we run RuboCop and our test suite. And it's a good thing. The change in the Responders gem from 3.0.1 to 3.1.0 is breaking a bunch our our Devise tests. Since we already have a story and an issue in our backlog to upgrade Devise, we manually modify the Gemfile.lock to stick with Responders 3.0.1. 

Come to think of it, this approach can also be used to solve our issue with the debug gem from the last time we tried to upgrade. We manually modify the Gemfile and Gemfile.lock with the new version and dependencies of debug. (This isn't a sustainable solution, but it will solve the problem for now.)

Now our tests are all passing and we are able to produce a passing build and merge a pull request with the fixes back into our main branch.

This video covers:
00:00:12 Introduction
00:03:37 Take a look at the previous commit where we upgraded a Ruby version
00:04:27 Update the .ruby-version and Gemfile to Ruby 3.2.1
00:05:15 Install Ruby 3.2.1 with RVM
00:06:10 Tell RVM to use 3.2.1 as the default Ruby
00:06:32 Run a general `bundle update` and see what happens with the debug gem and Dependabot-related gems
00:08:54 Run RuboCop and tests
00:09:35 A bunch of new test failures exist due to changes in the Responders gem. Manually set the responders version in the Gemfile.lock to 3.0.1 until we make the update to Devise
00:12:13 Re-run tests with the downgraded version of Responders
00:13:09 Manually modify Gemfile and Gemfile.lock to upgrade the debug gem.
00:15:32 Re-run RuboCop and tests
00:15:45 Check out a branch, review changes, commit, push
00:18:16 Open and merge pull request, resolve issue

#ruby #rails7 #rails #rubyonrails #rubygems #codecast #screencast #github #opensource #minitest #TDD #agile #NerdDice #DnD #roleplaying #softwaredevelopment #learntocode #tailwind #postgresql #rubocop #devise #turbo #controllers #views #selenium #capybara #systemtest #dependabot #rvm #debug #responders

See other related StatelessCode videos:
- Upgrade a Rails 7.0 App to Ruby 3.1.3 https://youtu.be/DFvzWcAx-Rc
- Update a Rails 7 Application to use Ruby 3.2 https://youtu.be/C_UzpLST3us
- Update Bundle to Clear Dependabot Alerts and Troubleshoot Build Dependency Failures https://youtu.be/rMlolATu73U

This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE.  Stateless Code denies the concept of "intellectual property". Copying is not stealing.