简体   繁体   中英

Migration to Rails 5, rails gem issue

I am trying to migrate from Rails 4.2 to Rails 5.0 (running on ruby 2.3) (see plan here https://stackoverflow.com/a/38443616/7374136 )

The plan is to:

  1. Update the rails gem and all dependencies.
  2. Run tests (covering almost our whole code base) for depreciations and fix them.
  3. Run rake rails:update toupdate Rails
  4. Adapt the configuration, application classes, breaking changes, ...

Nevertheless, I am blocked at the first step already, updating the rails gem and dependencies. gem 'rails', '4.2.5' -> gem 'rails', '~> 5.0' running: bundle update rails .

I faced multiple dependencies issues, which I fixed by looking for any dependencies that ultimately require rails to be less than 5, and see if those can be updated. Running:

bundle update rails tolk rspec-rails globalize active_model_serializers simple_form postmark-rails > rails_update_report.txt

I end up with a Gemfile as follows:

source 'https://rubygems.org'

# ruby '2.3.2'
gem 'bundler', '>= 1.11.2'

#core
gem 'rails', '~> 5.0'
gem 'pg'
gem 'puma'

#rest-client
gem 'httparty'

#rails-extension
gem 'rails-i18n', '~> 4.0', '>= 4.0.8'
gem 'active_model_serializers', '~> 0.10.7'
gem 'devise', '~> 3.5.6'
gem 'devise-i18n'
gem 'devise-i18n-views'
gem 'draper', '~> 2.1.0'
gem 'interactor', '~> 3.1'
gem 'rack-cors', :require => 'rack/cors'
gem 'globalize', '~> 5.1'
gem 'globalize-accessors', '~> 0.2.1'
gem 'kaminari'
gem 'tolk', '~> 3.1'
gem 'reform', '~> 2.1.0'
gem 'reform-rails', '~> 0.1.0'
gem 'virtus', '~> 1.0.5'
gem 'validates_timeliness', '~> 4.0'
gem 'pundit', '~> 1.1.0'
gem 'time_difference'
gem 'phonelib', '~> 0.5.6'
gem 'jwt', '~> 1.5'
gem 'pdf-forms', github: 'jkraemer/pdf-forms', branch: "1.0.0"
gem 'combine_pdf', '~> 0.2.21'
gem 'pdf-reader'

#markdown
gem 'redcarpet'

#files upload and images handling
gem 'carrierwave', '~> 0.11.2'
gem 'fog-aws'
gem 'file_validators'
gem 'mini_magick'
gem 'remotipart'
gem 'carrierwave-imageoptimizer'
gem 'fastimage'

#front
gem 'sass-rails', '~> 5.0'
gem 'uglifier'
gem 'coffee-rails', '~> 4.1.1'
gem 'jquery-rails'
gem 'jquery-cookie-rails'
gem 'foundation-rails'
gem 'slim-rails'
gem 'simple_form', '~> 4.0', '>= 4.0.1'
gem 'cocoon', '~> 1.2.8'
gem 'font-awesome-rails', '~> 4.5'
gem 'jquery-slick-rails'
# gem 'dropzonejs-rails'

# misc
gem 'sentry-raven'
gem 'postmark-rails', '~> 0.18.0'
gem 'chargebee'
gem 'split', require: 'split/dashboard'

# Note that backup is actually a stand alone app packaged as a ruby gem!
gem 'backup',   require: false
gem 'whenever', require: false

#Delayed Jobs
gem 'sidekiq'
gem 'sidekiq-client-cli'

group :development, :test do
  gem 'quiet_assets'
  gem 'rspec-rails', '~> 3.8', '>= 3.8.1'
  gem 'factory_girl_rails', require: false
  gem 'faker'

  gem 'pry-rails'
  gem 'pry-rescue'

  gem 'bullet'
  gem 'active_record_query_trace'
end

group :development do
  gem 'better_errors'
  gem 'spring'
  gem 'spring-commands-rspec'
  gem 'binding_of_caller'
  gem 'foreman'
  gem 'i18n_yaml_sorter'

  gem 'capistrano', '~> 3.4', require: false
  gem 'capistrano-rails', require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano-rbenv', require: false
  gem 'capistrano-db-tasks', require: false
  gem 'capistrano-maintenance', '~> 1.0', require: false
  gem 'airbrussh', require: false
  gem 'highline', require: false
  gem 'capistrano-faster-assets', require: false
  gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
end

group :test do
  gem 'capybara', require: false
  gem 'database_cleaner', require: false
  gem 'launchy', require: false
  gem 'site_prism', require: false
  gem 'memoist'

  gem 'rspec-collection_matchers', require: false
  gem 'poltergeist', require: false
  gem 'selenium-webdriver', require: false
  gem 'capybara-screenshot', require: false
  gem 'webmock', require: false
  gem 'email_spec', require: false

  gem 'rspec-sidekiq'
end

And I get the following error:

Could not find gem 'rails (~> 5.0)', which is required by gem 'dropzonejs-rails', in any of the sources.

The complete report is:

Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies..............
Bundler could not find compatible versions for gem "actionmailer":
  In Gemfile:
    postmark-rails (~> 0.18.0) was resolved to 0.18.0, which depends on
      actionmailer (>= 3.0.0)

    rails (~> 5.0) was resolved to 5.0.0, which depends on
      actionmailer (= 5.0.0)

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    active_model_serializers (~> 0.10.7) was resolved to 0.10.7, which depends on
      actionpack (< 6, >= 4.1)

    draper (~> 2.1.0) was resolved to 2.1.0, which depends on
      actionpack (>= 3.0)

    kaminari was resolved to 0.16.3, which depends on
      actionpack (>= 3.0.0)

    rails (~> 5.0) was resolved to 5.0.0, which depends on
      actionpack (= 5.0.0)

    simple_form (>= 4.0.1, ~> 4.0) was resolved to 4.0.1, which depends on
      actionpack (>= 5.0)

    slim-rails was resolved to 3.1.1, which depends on
      actionpack (>= 3.1)

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    globalize (~> 5.1) was resolved to 5.1.0, which depends on
      activerecord (< 5.2, >= 4.2)

    rails (~> 5.0) was resolved to 5.0.0, which depends on
      activerecord (= 5.0.0)

Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (~> 5.0)

    dropzonejs-rails was resolved to 0.8.2, which depends on
      rails (> 3.1)

Could not find gem 'rails (~> 5.0)', which is required by gem 'dropzonejs-rails', in any of the sources.

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (~> 5.0) was resolved to 5.0.0, which depends on
      railties (= 5.0.0)

    rails-i18n (>= 4.0.8, ~> 4.0) was resolved to 4.0.9, which depends on
      railties (~> 4.0)

I am facing an issue that I can't work around. Can someone help me?

It sounds like you've already got the "look for a blocking dependency, then fix it" cycle under control.

The one that currently needs attention is at the very bottom:

rails-i18n (>= 4.0.8, ~> 4.0) was resolved to 4.0.9, which depends on
  railties (~> 4.0)

IMO it's good to keep the version numbers and ranges out of the Gemfile and only in the Gemfile.lock . That way, you only have to look one place to resolve these things. So, when you add a gem, go ahead and put it with its version spec in the Gemfile , do bundle install and get it installed, then remove the version spec from the Gemfile and leave it in the Gemfile.lock , where bundler will have automatically put it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM