Ruby

Learn how to deploy Ruby applications with Hatchbox

Updated

Hatchbox precompiles many Ruby versions to make your deployments fast. You can also specify other Ruby versions and they will be compiled during deployment.

We encourage you to use the latest version of Ruby that you can so bugfixes and security patches are applied.

Ruby Versions


Ubuntu 26.04 Resolute

Ubuntu 24.04 Noble

Ubuntu 22.04 Jammy

Ubuntu 20.04 Focal

Ruby 4.0

Ruby 3.4

Ruby 3.3

Ruby 3.2

Ruby 3.1

Ruby 3.0

Ruby 2.7

Ruby 2.6.10

Ruby 2.5.9

Ruby 2.4.10

Ruby 2.3.8

Ruby 2.2.10

Ruby 2.1.10

Ruby 2.0.0-p648

Ruby 1.9.3-p551

Ruby 1.8.7-p374

Older Ruby versions may have issues with newer Ubuntu LTS versions as glibc, openssl, and other dependencies have changed since they were released.

YJIT Support

Ruby 3.2 and newer are compiled with YJIT support.

Rails 7.2 and newer automatically enables YJIT with Ruby 3.3 or newer. Otherwise, you can enable YJIT with an environment variable:

  • RUBY_YJIT_ENABLE=1
  • RUBYOPT="--yjit"

There are several different ways to specify a Ruby version in your application.

Specifying a Ruby version

Hatchbox looks in multiple locations to find a Ruby version.

.ruby-version file

This is the most common option. New Rails applications will create this file automatically.

Simply put the Ruby version into this file and commit it to your repository.

echo "4.0.1" > .ruby-version
git add .ruby-version
git commit -m "Set Ruby version"

.tool-versions file

Another common file for version managers is the .tool-versions file. It works the same as .ruby-version but supports multiple languages.

echo "ruby 4.0.1" > .tool-versions
git add .tool-versions
git commit -m "Set Ruby version"

Gemfile

You may also specify the Ruby version in your Gemfile.

ruby "4.0.1"

You'll need to run bundler to add this to the Gemfile.lock

bundle install
git add Gemfile Gemfile.lock
git commit -m "Set Ruby version"