Recently, while updating gem versions in a Rails project, I contemplated a process with reasonable steps. This approach ensures we don't update too many components at once, allowing us to effectively handle any errors and quickly identify what might have broken the system.
Check project status
First, I assess the project's status. This includes determining the number of outdated gems, identifying the group with the most outdated gems, and evaluating the extent of the outdatedness – whether it involves many patch or minor versions, or if the project lags behind by several major versions.
```shell $ bundle outdated Resolving dependencies............................ Gem Current Latest Requested Groups actioncable 7.0.8 7.1.2 >= 0 default actionmailbox 7.0.8 7.1.2 actionmailer 7.0.8 7.1.2 actionpack 7.0.8 7.1.2 actiontext 7.0.8 7.1.2 actionview 7.0.8 7.1.2 activejob 7.0.8 7.1.2 activejob-uniqueness 0.2.5 0.3.1 >= 0 default activemodel 7.0.8 7.1.2 activerecord 7.0.8 7.1.2 activestorage 7.0.8 7.1.2 activesupport 7.0.8 7.1.2 ....
Update by sections
Then, I divide the update into steps, validating each one by running the project's tests.
Normally I start just updating whatever version it's needed (patch, minor and major) for development and test
```shell $ bundle outdated -g development -g test # Check outdated gems by groups $ bundle update -g development -g test # Update only specific groups
Next, run the project tests. Depending on your project setup, this can be done either locally on your machine or in the CI environment.
```shell $ bundle outdated --patch # Check gems outdated by patch versions only $ bundle update --patch # Update gems outdated by patch versions only # Run Test Suite
Continue with minor
```shell $ bundle outdated --minor $ bundle update --minor # Run Test Suite
Continue with major
```shell $ bundle outdated --major $ bundle update --major # Run Test Suite
It's a good practice to thoroughly review the changelogs for gems updated by major versions. This helps in understanding the changes and potential impacts on your project. To do this you can check https://rubygems.org/ and see if the changelog is linked in the "Links" section of the gem, you can check releases on Github, or the CHANGELOG.md file in Github too.
Also, another interesting tool for this is https://my.diffend.io/gems, where you can compare two different versions of the same gem for example https://my.diffend.io/gems/sidekiq/6.5.5/7.2.0
Conclusion
This straightforward process aids in understanding your starting point and allows you to update gems in small chunks. If an issue arises, you won't have to sift through the entire list of outdated gems in your Gemfile to pinpoint the problematic one.