· Chris Hammond
Last Updated

How to Upgrade Ruby on Ubuntu 22.04 Using rbenv

Instructions for how to upgrade Ruby on Ubuntu 22.04 Using rbenv to allow for having multiple versions of Ruby installed.

Instructions for how to upgrade Ruby on Ubuntu 22.04 Using rbenv to allow for having multiple versions of Ruby installed.

How to Upgrade Ruby on Ubuntu 22.04 Using rbenv

Upgrading Ruby on Ubuntu can be smoothly handled with a version manager like rbenv. This approach is not only efficient but it also allows for easy switching between different Ruby versions. Below is a step-by-step guide on installing rbenv and using it to upgrade Ruby to your desired version.

Installing rbenv and Ruby-build

Follow these steps to set up rbenv and ruby-build on your system:

  1. Install rbenv and ruby-build: This step involves pulling rbenv and its plugin ruby-build from GitHub, which helps in managing multiple Ruby versions.
    sudo apt update sudo apt install -y git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-installer | bash 
  2. Configure rbenv integration: Add rbenv to your shell to enable shims and autocompletion by appending the following lines to your shell configuration file.
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL 

    If you use zsh, replace .bashrc with .zshrc.

  3. Check the rbenv installation: Ensure that rbenv is integrated correctly into your shell.
    type rbenv

    This command should output "rbenv is a function".

Installing Ruby 3.2.3 or 3.3

Once rbenv is set up, proceed to install a new Ruby version:

  1. List all available versions of Ruby:
    rbenv install -l

    Look for the latest stable versions or any specific version you wish to install.

  2. Install Ruby:

    If Ruby 3.2.3 or another version like 3.3 is available, install it using:

    rbenv install 3.2.3  # Replace 3.2.3 with the desired version rbenv global 3.2.3   # Set the installed version as the default
  3. Verify the installed Ruby version:
    ruby -v

    This command will display the Ruby version you have set as default, confirming the successful installation.

By following these steps, you can manage different Ruby versions on your Ubuntu system effectively, allowing you to develop and test Ruby applications with ease.

Back to Blog

Related Posts

View All Posts »