[RAILS] What I did in the version upgrade from Ruby 2.5.2 to 2.7.1


The Ruby version of the website running on AWS is 2.5.2, and this version of EOL (End Of Life) is 2020/12/25, and the date is approaching. Therefore, I decided to upgrade Ruby. (The following is an excerpt of the warning on AWS)

 ###### WARNING:
remote:        Potential EOL Ruby Version
remote:        You are using a Ruby version that has either reached its End of Life (EOL)
remote:        or will reach its End of Life on December 25th of this year.
remote:        We suggest you upgrade to Ruby 2.6.x or later
remote:        Once a Ruby version becomes EOL, it will no longer receive
remote:        security updates from Ruby core and may have serious vulnerabilities.
remote:        Please upgrade your Ruby version.
remote:        For a list of supported Ruby versions see:
remote:          https://devcenter.heroku.com/articles/ruby-support#supported-runtimes


・ Upgrade of Ruby running on AWS Cloud9 ・ Upgrade from Ruby 2.5.2 to 2.7.1 ・ Rails ・ I don't think it's relevant because it's a version upgrade on AWS, but I access and work on AWS on MacOS 10.15.7 (Catalina).

Version upgrade

Find out which version of Ruby you can install

$ rbenv install --list

Specify the version of Ruby you want to install and execute the version upgrade

$ rbenv install 2.7.1

Check the installed Ruby version

$ rbenv versions 
 * 2.7.1 (set by /home/ec2-user/environment/eventorg/.ruby-version)

When you want to reflect the Ruby version in the entire environment

$ rbenv global 2.7.1

When you want to reflect only a specific project

$ rbenv local 2.7.1

Next, if you specify the Ruby version to 2.7.1 in the Gemfile and check the ruby ​​version with the command,

$ ruby -v
  Your Ruby version is 2.5.2, but your Gemfile specified 2.7.1

I get an error.

After running rvm install "ruby-2.7.1", running ruby ​​-v,

$ ruby -v
 ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

Is output and the error disappears.

Install Gem on a new version of Ruby

$ gem install bundler

After the version of Ruby in the Gemfile is 2.7.1, execute the following

$ bundle install --path=vendor/bundle

When I install a new version of Ruby, I can't use the rails command

$ rails --version
rbenv: rails: command not found

Therefore, update the gem

$ gem update --system

Install bundler

$ gem install bundler

install rails

$ gem install rails

Check the Rails version

$ rails --version

Now you can use the rails command. I ran $ rails s and I was able to access the app, so the version upgrade is complete


The work will flow in the order of Ruby-> Gem-> Rails for version upgrade. When I was aware of these three lumps, I thought that the image of the version upgrade was easy to get excited. We hope for your reference.

Reference article

Upgrade of ruby 【Ruby】Your Ruby version is 2.6.3, but your Gemfile specified 2.5.8 Ruby version change

that's all

Recommended Posts

What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
[Rails] I tried to raise the Rails version from 5.0 to 5.2
I want to get the value in Ruby
Tokoro I rewrote in the migration from Wicket 7 to 8
paiza Ruby What I did to become B rank
I tried upgrading from CentOS 6.5 to CentOS 7 with the upgrade tool
I want to change the value of Attribute in Selenium of Ruby
[Android] I want to get the listener from the button in ListView
[Ruby] From the basics to the inject method
I tried to build Ruby 3.0.0 from source
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
[Ruby] I want to output only the odd-numbered characters in the character string
What I did when JSF couldn't display database information in the view
I tried to solve the tribonacci sequence problem in Ruby, with recursion.
I thought about the best way to create a ValueObject in Ruby
I tried to make full use of the CPU core in Ruby
[Ruby] I tried to summarize the methods that frequently appear in paiza
[Ruby] I tried to summarize the methods that frequently appear in paiza ②
I had to lower the PHP version in Docker + Composer + Laravel environment
I want to find out what character the character string appears from the left
What is CHECKSTYLE: OFF found in the Java source? Checkstyle to know from
I tried to organize the session in Rails
The ruby version is managed in the .rbenv / version file
I want to use arrow notation in Ruby
What I did when I converted java to Kotlin
How to build the simplest blockchain in Ruby
[heroku deployment procedure ③] From Ruby version specification to deployment and access to the application (complete)
I tried to solve the tribonatch sequence problem in Ruby (time limit 10 minutes)
I tried to get the distance from the address string to the nearest station with ruby
What is ... (3 dots) found in the Java source? Variadic arguments to know from
From Java to Ruby !!
I was addicted to the NoSuchMethodError in Cloud Endpoints
I tried to organize the cases used in programming
[Java] I want to calculate the difference from the date
I want to embed any TraceId in the log
What should I do to reload the updated Dockerfile?
What I got from continuing to develop open source
[Rilas] What I learned in implementing the pagination function.
I tried to implement the Euclidean algorithm in Java
What I stumbled upon in the ActiveModel :: Serializer test
I tried to find out what changed in Java 9
Library not loaded when trying to upgrade the version of ruby and rails s
A memo of what I did from a blank state to searching for characters using the "grep command" on "Ubuntu"
I changed the Ruby version and now I can't bundle install
I tried to make an application in 3 months from inexperienced
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
Understand the rough flow from request to response in SpringWebMVC
What I was addicted to when introducing the JNI library
I want to set the conditions to be displayed in collection_check_boxes
In Java, I want to trim multiple specified characters from only the beginning and end.
I want to perform high-speed prime factorization in Ruby (ABC177E)
What to do if you installed Ruby with rbenv but the version does not change
How to retrieve the hash value in an array in Ruby
I tried to summarize the basic grammar of Ruby briefly
What I was addicted to with the Redmine REST API
I want to create a Parquet file even in Ruby
What you need to do to open a file from the menu in the document-Based App macOS app
I want to transition to the same screen in the saved state
I want to recreate the contents of assets from scratch in the environment built with capistrano