By default, Ruby is already installed in different Linux-based operating systems, including Raspberry Pi OS. However, the version is quite old and cannot be updated through the repository update command. This article will show you how to update the Ruby version on Raspberry Pi.
How to Update Ruby on Raspberry Pi
Having the latest version of Ruby will help Raspberry Pi users efficiently create web applications faster than the old version. The Raspberry Pi system includes the old version of Ruby, which you can confirm from the following command:
The above command confirms that the Raspberry Pi system includes Ruby version 2.7.4, an older version. The latest stable version right now is “3.1.3”. You can visit here to check for Ruby’s latest update. The method is similar to all versions as you just need to replace the version with “3.1.3”.
To update the Ruby version on Raspberry Pi, follow the below-mentioned steps:
Step 1: Install the Latest Ruby Version
The rbenv is a version manager tool that allows users to update the Ruby version on the system easily. Since the latest version is “3.1.3”, you can use the following command to install the latest version of Ruby on the Raspberry Pi system.
Note: Replace “3.1.3” with the latest version in case any update occurs later.
The process takes time to install the latest Ruby version on the Raspberry Pi system.
Step 2: Set Default Ruby Version on Raspberry Pi
To globally set the default Ruby version on Raspberry Pi, follow the below-mentioned command:
Step 3: Confirm Ruby Version on Raspberry Pi
To confirm the Ruby version is successfully updated on Raspberry Pi, you should use the following command:
The above output confirms that Ruby is successfully updated on the Raspberry Pi system.
Conclusion
Ruby is an object-oriented programming language widely used for web development. Though it’s already installed on the Raspberry Pi system, you must update it to the latest version for improved performance. You can easily update Ruby on Raspberry Pi through the “rbnev” command and then set the default version to the latest one using “rbnev global” command.