简体   繁体   English

迁移到 Rails 5,rails gem 问题

[英]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 )我正在尝试从 Rails 4.2 迁移到 Rails 5.0(在 ruby​​ 2.3 上运行)(请参阅此处的计划https://stackoverflow.com/a/38443616/7374136

The plan is to:计划是:

  1. Update the rails gem and all dependencies.更新rails gem和所有依赖项。
  2. Run tests (covering almost our whole code base) for depreciations and fix them.运行测试(几乎涵盖我们的整个代码库)以进行折旧并修复它们。
  3. Run rake rails:update toupdate Rails运行rake rails:update更新 Rails
  4. Adapt the configuration, application classes, breaking changes, ...调整配置、应用程序类、重大更改……

Nevertheless, I am blocked at the first step already, updating the rails gem and dependencies.尽管如此,我已经在第一步被阻止,更新rails gem和依赖项。 gem 'rails', '4.2.5' -> gem 'rails', '~> 5.0' running: bundle update rails . 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.我遇到了多个依赖项问题,我通过查找最终要求 rails 小于 5 的任何依赖项来解决这些问题,并查看是否可以更新这些依赖项。 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:我最终得到一个 Gemfile,如下所示:

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 . IMO 最好将版本号和范围保留在Gemfile并且只保留在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.所以,当你添加一个 gem 时,继续将它的版本规范放在Gemfile ,执行bundle installbundle install它,然后从 Gemfile 中删除版本规范并将其保留在Gemfile.lock ,bundler 将在那里自动把它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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