Update a Rails 7 Application to use Ruby 3.2
Channel: Stateless Code
Date: 02/01/2023

Even though we just updated our application to Ruby 3.1.3 in the previous video, we're going to bump the upgrade of our app to Ruby 3.2.

We follow a very similar process to what we used to upgrade from Ruby 3.1.2 to Ruby 3.1.3 in the previous video. All of the files we need to modify are still open in the editor.

Our system is Ubuntu 22.04 and we are using Ruby Version Manager (RVM) to manage our Ruby installations. We already have Ruby 3.2.0 installed on our system from the Nerd Christmas 2022 video, but when we change to the NerdDice.com directory, we can see that we're still using Ruby 3.1.3. The version in our .ruby-version file takes precedence over our RVM default, so we need to specify `rvm use 3.2.0` in our directory in order for us to update the bundle. If you don't already have Ruby 3.2.0 installed on your system, you can execute `rvm install 3.2.0` and `rvm use 3.2.0 --default` to get the needed Ruby version onto your system.

After that, we modify our Ruby version in the .ruby-version file and the Gemfile. We run a `bundle install` and re-run RuboCop and our full test suite to make sure nothing breaks before committing and pushing the code. 

Unlike last time, every test now has a deprecation warning about Rack and its use of Regexp.new. The message is 3rd argument to Regexp.new is deprecated and will be removed in Ruby 3.3; use 2nd argument instead

It's not uncommon to see a slew of new deprecation warnings across our set of gems, but this is just one line of one file in Rack. We check RubyGems.org to see if new versions of Rack have been released. There is a 3.x version, but that is not supported by the version constraints of our current version of Rails ActionPack (7.0.4). We run `bundle update rack` and it updates our patch version from 2.2.4 to 2.2.5 and the deprecation warnings are gone.

This video covers:
00:00:12 Introduction
00:01:49 Take a look at current RVM Ruby versions
00:02:33 Look at previous commit for changes that need to be made
00:03:27 Make needed updates to files
00:04:41 Use rvm on the working directory to use Ruby 3.2.0 and update Gemfile.lock to use bundler 2.4.1
00:05:17 Run `bundle install` and review git diff
00:07:15 Run RuboCop and full test suite
00:08:14 Fix deprecation warnings by updating Rack and rerun tests
00:10:53 Smoke test application on Rails development server
00:12:37 Review, commit, and push code
00:13:41 Prune old branch from previous video
00:14:40 Open and merge pull request; update project 
00:18:39 Outtake

#ruby #rails7 #rails #rubyonrails #rubygems #rvm #codecast #screencast #github #opensource #minitest #TDD #agile #NerdDice #DnD #roleplaying #softwaredevelopment #learntocode #rubocop #selenium #capybara #systemtest #deprecationwarning #rack

See other related StatelessCode videos:
- Upgrade a Rails 7.0 App to Ruby 3.1.3 https://youtu.be/DFvzWcAx-Rc
- Nerd Christmas 2022 - Ruby 3.2 Released! https://youtu.be/YPXum1WtuH0

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.