You're probably following a tutorial for this. Did the tutorial told you to use Rbenv? or RVM?
You might have already tried this, but in case you have not, here is what I would do:
sudo apt install ruby-full
ruby --version
Now if you truly want to use RVM or Rbenv, you might need to review their installation. Also, you COULD TRY running this command:
sudo apt install build-essential
If it still does not work, try the above mentionned answer. Hope I could help!
Answer from Hwiparam on Stack OverflowUnable to Install Ruby 3.0.2 on Ubuntu 22.10 - Stack Overflow
Install later versions of Ruby in Ubuntu 18.04 using apt
How to install ruby 3.1.2 in an Ubuntu Docker container? - Stack Overflow
What is the correct way to install ruby on ubuntu 22.04 - Stack Overflow
Videos
I would like to install ruby version 2.7.4 using apt in Ubuntu 18.04. Using the below command:
sudo apt install ruby-full
But I am able to install only older versions. Is there a way to install the specified version using apt?
What works for me is to run
rvm pkg install openssl
and then
rvm install ruby-2.7.3 --with-openssl-dir=$HOME/.rvm/usr
Most people who arrive here from Google are likely running the following:
rvm install ruby
As of writing, this will install ruby 3.0.0 which will give you a build error on Ubuntu 22.04.
Most people probably want to install the latest 3.1.0, which does not show when running rvm list known.
To install the latest (which is currently 3.1.0) run:
rvm install ruby-3.1.0
The latest will install fine on Ubuntu 22.04.