Today, let’s explore how to install ruby on your Ubuntu 22.04 Box, and run a test script to print Hello World!
Step #1 Prepare your Ubuntu for Ruby installation
As always, it is recommended to start with updating your Ubuntu package index.
sudo apt update
Step #2 Run the package installation step
Run the ruby installation command using apt
sudo apt install ruby-full -y
With this, you have your latest ruby development environment ready. Next, go on and test it.
Step #3 Check the installation version & test run the ruby hello world
Although you could see which version is being installed when you run the apt command, later to get the installation version any time, you can check using the ruby -v command
[email protected]:~$ ruby -v ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
Let’s create our first ruby script.
echo 'puts "Hello CodeTryout" ' > myscript.rb
Testing the hello-world program.
This will run and output like:
[email protected]:~$ ruby myscript.rb Hello CodeTryout
Try ruby without installing it
I found this resource very helpful to try ruby in your browser without installing it.
I have tried and tested these ruby installation steps on Ubuntu Virtualbox, Ubuntu version 20.04, and the exact steps will work on Ubuntu 22.04 as well.
Good luck with your ruby programming!