While installing older ruby versions on macOS Catalina you may encounter errors regarding openssl. This is due to the dependency on openssl version 1.0. To compile ruby from source you will need to install openssl version 1.0.

I faced similar problem, while installing ruby version 2.2.5 on macOs Catalina. Following solution helped to install old ruby version successfully.

Steps

1. Install openssl v1.0

brew install rbenv/tap/openssl@1.0

2. Install ruby-2.2.5 by referencing openssl v1.0

CFLAGS="-Wno-error=implicit-function-declaration" \
rvm reinstall ruby-2.2.5 --with-openssl-dir='/usr/local/opt/openssl@1.0'