How can we downgrade from ruby 2.7.1 to ruby 2.3.1?

We found that ruby and rails projects are version agonistic in many cases. In our case, the rails project was built with ruby 2.3.1 and rails 4.2.6. We wanted to run the project using ruby 2.7.1 but it failed miserably. We then decided to downgrade the ruby version to 2.3.1.

It is possible to have multiple ruby versions installed in the system and switch the ruby version as we need. We can do it very easily using RVM (Ruby version manager). If we have rvm installed then we can run the following command.

$ rvm list
   ruby-2.7.0 [ x86_64 ]
 * ruby-2.7.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

From the command, we see that we have ruby 2.7.1 installed and we need to install 2.3.1 on our system to run the project. If we have rvm installed we can run the following command to install ruby 2.3.1

$ rvm install ruby-2.3.1

If it complains about openssl we can run the following command:

$ rvm install ruby-2.3.1  --with-openssl-dir=$rvm_path/usr

How to change ruby version?

This command will change the ruby version for a console session
$ rvm --default use ruby-2.3.1