chruby is a Ruby versioning manager and it’s my favorite Ruby versioning manager. I’ve use it in production server in since 2017. In this post I will explain how to install new Ruby version 3.1.0 with chruby and remove old version Ruby 3.0.0.

How to Install MRI Ruby with chruby on Ubuntu

CRuby or MRI (Matz’s Ruby Implementation) is original Ruby implementation. To install MRI Ruby with chruby on Ubuntu, you need install all Ruby’s dependencies first.

MRI Ruby Requirements

  • MRI Ruby requires OpenSSL >= 1.0.1.

  • Install the following linux command to install Ruby’s dependencies for Ubuntu.

      sudo apt-get install -y build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libffi-dev

MRI Ruby 3.1.0 Installation for chruby

tar -xvzf ruby-3.1.0.tar.gz
cd ruby-3.1.0
./configure --prefix=/opt/rubies/ruby-3.1.0
sudo make install

How to Uninstall MRI Ruby 3.0.0 from chruby

If Ruby installation with chruby use /opt/rubies as target directory, run the following commands to uninstall Ruby from chruby.

sudo rm -rf /opt/rubies/ruby-3.0.0/