Skip to main content
Last updated: 26 Jan 2022

Add a new Ruby version

The Ruby language is a core part of GOV.UK - most of our applications are written in it.

Managing different versions of Ruby

Each app can use whatever version of Ruby it wants. We manage this with rbenv.

Setting up rbenv

We set up rbenv differently depending on what’s going on:

  • Interactive login shells: /etc/profile.d/ sets up rbenv
  • Applications: govuk_setenv and a .ruby-version in the app directory set up rbenv
  • Deployment: Capistrano uses a non -login shell so we set default_environment (commit)
  • Testing: Jenkins uses a non-login shell so we add /usr/lib/rbenv/shims to the PATH
  • Cronjobs: some cronjobs start with /bin/bash -l -c which runs a login shell

Add a new Ruby version in puppet

You will need to build a new fpm package with the new Ruby version. This package can then be copied to Aptly machine, and the new version added to puppet.

Building the fpm package.

Add to Puppet

Once it’s available as a package in Aptly you can install it everywhere using Puppet. However, machines only run apt-get update periodically (nightly) so it might take time for the package to become available.

You can speed things along by SSH'ing into the relevant machine and running sudo apt-get update, then govuk_puppet --test. You should see a successful Ruby install as part of the Puppet run.

You’ll need to do that on jenkins (and, if impatient, each of the ci_agent machines) first to get the PR’s tests passing, and then on the respective machine that your app will run on (e.g. backend).

Update Ruby version in the relevant repos

We use upgrade-ruby-version to automatically raise pull requests in GOV.UK repositories which use Ruby. See an example PR for how to specify the repos and versions.

Once the PRs are raised, each app should have that branch built to Integration, where it should be tested to ensure that the new Ruby version hasn’t caused any problems. Our monitoring tools, such as Grafana and Sentry, should be checked too. Once fully tested, the PR should be safe to merge.