Raspberry Pi

How to Update Ruby on Raspberry Pi

Ruby is a dynamic and open-source object-oriented programming language that supports multiple programming paradigms. The language focuses more on simplicity and has a syntax that is easier to understand for a beginner. It is widely used for developing web applications since it is powerful, easy to learn and uses a few lines of code.

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:

$ ruby -v

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.

$ rbenv install 3.1.3

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:

$ rbenv global 3.1.3

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:

$ ruby --version

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.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.