rails upgrading from 5.0.0.1 to rails rails 5.1 issues in installing gems

111 Views Asked by At

I want to upgrade an old legacy app from rails 5.0 to rails 5.1 then so on until rails 7 I have dockerized the app for easiness please read the Gemfile, which gems are supported in Rails 7

terminal:

$ docker-compose run rails bundle install

terminal logs:

An error occurred while installing nio4r (2.5.8), and Bundler cannot continue.

In Gemfile:
  rename was resolved to 1.0.8, which depends on
    rails was resolved to 5.2.8.1, which depends on
      actioncable was resolved to 5.2.8.1, which depends on
        nio4r

this is my Gemfile: app/Gemfile

I have removed the Gemfile.lock to avoid conflicts in version that were locked

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem 'rails', '~> 5.1'
gem 'mysql2'
gem 'sassc'
gem 'sass'
# gem 'sass-rails',  git:'https://github.com/sass/sassc-rails.git', branch: 'master'
gem 'sassc-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'js_cookie_rails'
gem 'jbuilder'
gem 'sdoc', group: :doc
gem 'rake'
gem 'kaminari'
gem 'slim-rails'
gem 'rack-user_agent'
gem 'gmail'
gem 'whenever'
gem 'actionpack-action_caching'
gem 'breadcrumbs_on_rails'
gem 'execjs'
gem 'ltsv-logger'
gem 'therubyracer'

# 問い合わせなどの画像認証
gem 'scout_apm'

gem "recaptcha", require: "recaptcha/rails"

gem 'sentry-raven'
gem 'faraday'
gem 'faraday_middleware'
gem 'config'
gem 'font-awesome-rails' 
1

There are 1 best solutions below

0
iftheshoefritz On

Are you working from the Rails guide for updating versions?

Don't start with Rails 7 in mind. Just do one minor version bump at a time (5.1, 5.2, 6.0 etc... you don't have to worry about patch numbers) and make sure it works in production before moving on.

Also, if there are changes that break in version x.x, you can usually make those changes in x.x-1 before you upgrade to x.x. I suggest doing as much as you can before you get to the point of upgrading Rails and other gems.

In this case, is your app already working with Rails 5.1 (and how have you evaluated that)?

Bundler is trying to install Rails 5.2 because rails '~> 5.1' will find the latest 5.x version that is equal or greater than 5.1. If you're not sure your app is working on 5.1 yet, start there by adding a patch version so you get the latest 5.1.x: `gem 'rails', '~> 5.1.0'.

Once you've got the version number right in your Gemfile, you're on to the next step of the guide:

Change the Rails version number in the Gemfile and run bundle update

(now do the rest of the steps)