All Collections Ruby on Rails How do I specify a Ruby version for my app?

How do I specify a Ruby version for my app?

Let Hatchbox know which Ruby version to run your application

Updated

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

.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"