How do I specify a Ruby version for my app?

Choosing the Ruby version lets Hatchbox know which exact version of Ruby to use when deploying

Written by Chris Oliver
Updated over a week ago
You have a few options to specify your Ruby version with Hatchbox. See for a list of versions you can use with Hatchbox.

`.ruby-version` file
Most Ruby version managers will read this file, so it's likely you might have this already. You'll write the Ruby versionĀ 

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

`Gemfile`
You can specify required Ruby versions in your Gemfile with the ruby method.

ruby "3.1.2"
bundle
git add Gemfile Gemfile.lock
git commit -m "Set ruby version"

`.tool-versions` file
Since we use ASDF for language management, you can add Ruby to a .tool-versions file in the root of your repository.

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

Git push and deploy
After you've set your Ruby version, push to your git repository and start a new deployment of your app on Hatchbox.

Was this article helpful?