When you install rbenv via apt on Ubuntu 20.4 it doesn't seem to see all the versions of ruby available
e.g this happened to me:
$ rbenv install 3.1.0
ruby-build: definition not found: 3.1.0
See all available versions with `rbenv install --list'.
If the version you need is missing, try upgrading ruby-build.
To upgrade ruby-build you need to clone it locally
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
After that, rbenv will see the versions you want.
If you ever get the error again you will need to do a git pull in the repo in ~/.rbenv/plugins/ruby-build