---
title: "Rails 6 requires Ruby 2.5 or newer"
description: "Rails 6 requires Ruby 2.5 or newer"
canonical_url: "https://www.bigbinary.com/blog/rails-6-requires-ruby-2-5-or-newer"
markdown_url: "https://www.bigbinary.com/blog/rails-6-requires-ruby-2-5-or-newer.md"
---

# Rails 6 requires Ruby 2.5 or newer

Rails 6 requires Ruby 2.5 or newer

- Author: Vishal Telangre
- Published: April 9, 2019
- Categories: Rails 6, Rails

As per [rails/rails#34754](https://github.com/rails/rails/pull/34754), a Rails 6
app requires Ruby version 2.5 or newer.

Let's discuss what we need to know if we are dealing with Rails 6.

## Ensuring a valid Ruby version is set while creating a new Rails 6 app

While creating a new Rails 6 app, we need to ensure that the current Ruby
version in the shell is set to 2.5 or newer.

If it is set to an older version then the same version will be used by the
`rails new` command to set the Ruby version in `.ruby-version` and in `Gemfile`
respectively in the created Rails app.

```plaintext
\$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

\$ rails new meme-wizard
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
[...] omitted the rest of the output

\$ cd meme-wizard && grep -C 2 -Rn -a "2.3.1" .
./.ruby-version:1:2.3.1
--
--
./Gemfile-2-git_source(:github) { |repo| "https://github.com/#{repo}.git" }
./Gemfile-3-
./Gemfile:4:ruby '2.3.1'
./Gemfile-5-
./Gemfile-6-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
```

An easy fix for this is to install a Ruby version 2.5 or newer and use that
version prior to running the `rails new` command.

```plaintext
\$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

\$ rbenv local 2.6.0

\$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]

\$ rails new meme-wizard

\$ cd meme-wizard && grep -C 2 -Rn -a "2.6.0" .
./.ruby-version:1:2.6.0
--
--
./Gemfile-2-git_source(:github) { |repo| "https://github.com/#{repo}.git" }
./Gemfile-3-
./Gemfile:4:ruby '2.6.0'
./Gemfile-5-
./Gemfile-6-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
```

## Upgrading an older Rails app to Rails 6

While upgrading an older Rails app to Rails 6, we need to update the Ruby
version to 2.5 or newer in `.ruby-version` and `Gemfile` files respectively.

## What else do we need to know?

Since
[Ruby 2.5 has added `Hash#slice` method](https://blog.bigbinary.com/2018/02/06/ruby-2-5-added-hash-slice-method.html),
the extension method with the same name defined by
`activesupport/lib/active_support/core_ext/hash/slice.rb` has been
[removed from Rails 6](https://github.com/rails/rails/pull/34754).

Similarly, Rails 6 has also [removed](https://github.com/rails/rails/pull/32034)
the extension methods `Hash#transform_values` and `Hash#transform_values!` from
Active Support in favor of the native methods with the same names which exist in
Ruby. These methods were
[introduced in Ruby 2.4 natively](https://blog.bigbinary.com/2017/06/14/ruby-2-4-added-hash-transform-values-and-its-destructive-version-from-active-support.html).

If we try to explicitly require `active_support/core_ext/hash/transform_values`
then it would print a deprecation warning.

```ruby

> > require "active_support/core_ext/hash/transform_values"

# DEPRECATION WARNING: Ruby 2.5+ (required by Rails 6) provides Hash#transform_values natively, so requiring active_support/core_ext/hash/transform_values is no longer necessary. Requiring it will raise LoadError in Rails 6.1. (called from irb_binding at (irb):1)

=> true
```

## Links

- [Human page](https://www.bigbinary.com/blog/rails-6-requires-ruby-2-5-or-newer)
