How to fix Ruby version incompatible issue in Netlify?

I hadn't posted in this blog for a while, and when I tried to push my changes live for netlify, I ran into this error

6:48:39 PM: rouge-4.1.0 requires ruby version >= 2.7, which is incompatible with the current
6:48:39 PM: version, ruby 2.6.2p47
6:48:39 PM: Error during gem install
6:48:39 PM: Build was terminated: Build script returned non-zero exit code: 1
6:48:40 PM: Failing build: Failed to build site
6:48:40 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
6:48:40 PM: Finished processing build request in 16.157s

To fix was really simple. This part of Netlify's useful documentation provides the answer.

So, to fix this rouge-4.1.0 requires ruby version >= 2.7, which is incompatible with the current version issue on Netlify:

  1. I added a .ruby-version file to my site’s base directory. In my case, all it says in the .ruby-version file is 2.7.0

After adding the file to my site, I pushed my changes, and it worked!

Want to learn how to code and make money online? Check out CodingPhase (referral link)