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.3 with chruby without YJIT and remove old version Ruby 3.2. If you are looking for the detail of Ruby installation with YJIT, see How to Install Ruby 3.3 with YJIT Enabled.

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 autoconf
    

How to Install MRI Ruby 3.2 without YJIT for chruby

wget https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.1.tar.gz
tar -xvzf ruby-3.3.1.tar.gz
cd ruby-3.3.1
./autogen.sh
./configure --prefix=/opt/rubies/ruby-3.3.1
sudo make install

How to Install MRI Ruby 3.3 with YJIT Enabled for chruby

Below is only command for Ruby installation with YJIT enabled, for the requirements see How to Install Ruby 3.3 with YJIT Enabled.

wget https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.1.tar.gz
tar -xvzf ruby-3.3.1.tar.gz
cd ruby-3.3.1

# Generate the configure file
./autogen.sh

# don't forget to create /opt/rubies directory
./configure --enable-yjit --prefix=/opt/rubies/ruby-3.3.1 --disable-install-doc

# If your machine have a lot of RAM, you can use `make -j install` to make installation faster
# `make install` compiles with a single cpu core only.
make install

How to Uninstall MRI Ruby 3.2 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.2.2/