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/rbenv.sh
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 thePATH
- 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 a new recipe for the ruby version in Packager. The folder name will be the Ruby version, and contain a
recipe.rb
file. See previous entries for examples. The recipe will require the SHA256 of the version’star.gz
, available at Ruby cache.Once the Packager change is merged, build the package.
Use the VM to test the recipe
To make sure it has been successful:
rbenv versions
to make sure your version is availablerbenv local X.X.X
to use your new versionruby -v
to make sure your version is in use
Copying to Aptly
Add to Puppet
Once it’s available as a package in Aptly you can
install it everywhere using Puppet. Machines only run
apt-get update
periodically so it might take a little time for the package
to become available.
Testing whether a version of Ruby is in use
You can use the Fabric task rbenv.version_in_use
to find out which
applications are using a specific version of Ruby on GOV.UK. For example:
fab production puppet_class:govuk_rbenv::all rbenv.version_in_use:2.3.1