Upgrading Ruby on your Mastodon server

When the minimum version of Ruby is increased for a new Mastodon release, you must upgrade Ruby before you can upgrade Mastodon to the new release.

Before you begin

Check the Mastodon installation documentation to see which version of Ruby is required. The need to upgrade Ruby isn't always clear in the Mastodon release notes. For example, the installation documentation shows that Mastodon 4.1.4 requires Ruby 3.0.6, but the release notes show Ruby 3.0.

When you try to upgrade Mastodon with an earlier version of Ruby, the bundle install command fails.

Procedure

  1. Connect to your Mastodon server by using ssh.
  2. Become the mastodon user by typing the following command.
    sudo su - mastodon
  3. Enter the Ruby virtual environment by typing the following command.
    cd .rbenv
  4. Remove the plugins folder by typing the following command.
    rm -rf plugins
  5. Clone the Ruby git repository by typing the following command.
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  6. Install Ruby by typing the following commands, where version is the required version number.
    RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install version
    rbenv global version

    For example, if you need to install Ruby 3.0.6, type the following commands:

    RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.6
    rbenv global 3.0.6

Results

The required version of Ruby is now installed. You can upgrade your Mastodon server.