The error was caused by an issue with the reline gem in the Ruby 2.7.2 setup. However, if I switch to another Ruby version (2.6.6) using rbenv global 2.6.6 everything seems to work fine.
Here's how I fixed it:
Solution 1:
Since the reline gem comes with Ruby installations, we will uninstall the ruby 2.7.2 version that is the cause of the issue using rbenv :
rbenv uninstall 2.7.2
Next, reinstall the ruby 2.7.2 version that is the cause of the issue using rbenv :
rbenv install 2.7.2
Afterwhich you will install the version of Bunder and Rails that you are using. In this case, my Rails version is Rails 6.1.3.1:
gem install bundler
gem install rails -v 6.1.3.1
rbenv rehash
You can afterwards, check the version of ruby, bundler and rails that were installed using the command below:
ruby -v
bundler -v
rails -v
This time when you try to test again using irb it should work fine.
Solution 2:
A faster approach will be to uninstall the reline gem in the Ruby 2.7.2 setup using the command below:
gem uninstall reline
And then reinstall it:
gem install reline
Note:
I did not test this to confirm if it fixes the issue.
That's all.
I hope this helps