【问题标题】:Rails 5 Upgrade, can't resolve dependenciesRails 5升级,无法解决依赖关系
【发布时间】:2019-08-29 01:19:55
【问题描述】:

从 Rails 4.2.8 升级到 Rails 5.0.2 会导致以下错误消息。我不确定如何解决依赖关系。红宝石版本是 2.5.1。我已经能够使用 Rails 4.2.8 运行这个应用程序和测试套件,虽然我看到较低版本的carrierwave 打印过多,所以我希望能够升级它,但它需要 Rails 5 .

错误信息

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    actionpack-action_caching was resolved to 1.2.0, which depends on
      actionpack (< 6, >= 4.0.0)

    rails (= 5.0.2) was resolved to 5.0.2, which depends on
      actionpack (= 5.0.2)

    simple_form was resolved to 4.1.0, which depends on
      actionpack (>= 5.0)

Bundler could not find compatible versions for gem "activemodel":
  In Gemfile:
    carrierwave was resolved to 2.0.0, which depends on
      activemodel (>= 5.0.0)

    rails (= 5.0.2) was resolved to 5.0.2, which depends on
      activemodel (= 5.0.2)

    simple_form was resolved to 4.1.0, which depends on
      activemodel (>= 5.0)

    validate_url was resolved to 1.0.8, which depends on
      activemodel (>= 3.0.0)

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    friendly_id (~> 5.1.0) was resolved to 5.1.0, which depends on
      activerecord (>= 4.0.0)

    rails (= 5.0.2) was resolved to 5.0.2, which depends on
      activerecord (= 5.0.2)

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    active_hash (~> 1.4.1) was resolved to 1.4.1, which depends on
      activesupport (>= 2.2.2)

    carrierwave was resolved to 2.0.0, which depends on
      activesupport (>= 5.0.0)

    rails (= 5.0.2) was resolved to 5.0.2, which depends on
      activesupport (= 5.0.2)

Bundler could not find compatible versions for gem "http":
  In Gemfile:
    http

    twitter (~> 5.15.0) was resolved to 5.15.0, which depends on
      http (< 0.10, >= 0.4)

Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (= 5.0.2)

    interactor-rails (~> 2.0) was resolved to 2.2.0, which depends on
      rails (< 5.3, >= 4.2)

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

    sass-rails (~> 5.0.1) was resolved to 5.0.8, which depends on
      railties (>= 5.2.0)

Bundler could not find compatible versions for gem "sprockets":
  In Gemfile:
    sprockets

    sass-rails (~> 5.0.1) was resolved to 5.0.8, which depends on
      sprockets (< 4.0, >= 2.8)

宝石文件

source 'https://rubygems.org'

ruby '2.5.1'

gem 'actionpack-action_caching'
gem 'active_hash', '~> 1.4.1'
gem 'avatars.io'
gem 'aws-sdk-s3', '~> 1'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'carrierwave'
gem 'carrierwave_direct'
gem 'coffee-rails', '~> 4.0.0'
gem 'compass-rails', '~> 2.0.2'
gem 'dalli'
gem 'devise'
gem 'diffy'
gem 'font-awesome-rails'
gem 'fog'
gem 'foundation-rails', '~> 5.5.3.2'
gem 'friendly_id', '~> 5.1.0'
gem 'haml'
gem 'html5shiv-js-rails'
gem 'http'
gem 'interactor-rails', '~> 2.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'pg'
gem 'puma', '~> 3.11.4'
gem 'rails', '5.0.2'
gem 'redcarpet'
gem 'rmagick'
gem 'ruby-mp3info', '>= 0.8.4'
gem 'sass-rails', '~> 5.0.1'
gem 'sidekiq'
gem 'sinatra', require: false
gem 'simple_form'
gem 'sprockets'
gem 'stamp'
gem 'twitter', '~> 5.15.0'
gem 'uglifier', '>= 1.3.0'
gem 'validate_url'
gem 'xml-simple', '~> 1.1.5'
gem 'will_paginate'

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'quiet_assets'
end

group :production do
  gem 'rails_12factor'
  gem 'scout_apm'
  gem 'sentry-raven'
  # gem 'unicorn-worker-killer'
end

group :test do
  gem 'factory_girl_rails'
  gem 'm'
  gem 'minitest-rails', '~> 2.2.0'
  gem 'simplecov', '~> 0.9', require: false
  gem 'timecop'
end

group :development, :test do
  gem 'dotenv-rails'
  gem 'pry'
  gem 'awesome_print'
end

【问题讨论】:

  • 我认为这是因为您正在修复很多 gem 的版本,运行 bundle 无法自动解决。尝试删除错误 gem 的固定版本,然后重试
  • 您是如何尝试更新到 Rails 5.0.2 的?您采取了哪些步骤,您是否运行了想要的命令?

标签: ruby-on-rails ruby rubygems ruby-on-rails-5


【解决方案1】:
    sass-rails (~> 5.0.1) was resolved to 5.0.8, which depends on
      railties (>= 5.2.0)

railties 5.2 将与 Rails 5.0 的其余部分发生冲突 - 您需要将 sass-rails 限制为 &lt; 5.0.8

【讨论】:

    【解决方案2】:

    先备份你的gemfile,然后试试这个

    source 'https://rubygems.org'
    
    ruby '2.5.1'
    
    gem 'actionpack-action_caching'
    gem 'active_hash'
    gem 'avatars.io'
    gem 'aws-sdk-s3'
    gem 'bootstrap-sass'
    gem 'carrierwave'
    gem 'carrierwave_direct'
    gem 'coffee-rails'
    gem 'compass-rails'
    gem 'dalli'
    gem 'devise'
    gem 'diffy'
    gem 'font-awesome-rails'
    gem 'fog'
    gem 'foundation-rails'
    gem 'friendly_id'
    gem 'haml'
    gem 'html5shiv-js-rails'
    gem 'http'
    gem 'interactor-rails'
    gem 'jquery-rails'
    gem 'jquery-ui-rails'
    gem 'pg'
    gem 'puma'
    gem 'rails'
    gem 'redcarpet'
    gem 'rmagick'
    gem 'ruby-mp3info'
    gem 'sass-rails'
    gem 'sidekiq'
    gem 'sinatra', require: false
    gem 'simple_form'
    gem 'sprockets'
    gem 'stamp'
    gem 'twitter'
    gem 'uglifier'
    gem 'validate_url'
    gem 'xml-simple'
    gem 'will_paginate'
    
    group :development do
      gem 'better_errors'
      gem 'binding_of_caller'
      gem 'quiet_assets'
    end
    
    group :production do
      gem 'rails_12factor'
      gem 'scout_apm'
      gem 'sentry-raven'
      # gem 'unicorn-worker-killer'
    end
    
    group :test do
      gem 'factory_girl_rails'
      gem 'm'
      gem 'minitest-rails'
      gem 'simplecov', require: false
      gem 'timecop'
    end
    
    group :development, :test do
      gem 'dotenv-rails'
      gem 'pry'
      gem 'awesome_print'
    end
    

    运行

    bundle update
    

    【讨论】:

    • 但是他们想要 Rails 5.0.2
    • 在你的 gem 文件中添加 rails gem "gem 'rails', '5.0.2' ",然后尝试命令:- gem install rails -v '5.0.2',然后尝试命令:- bundle安装。你在使用 gemset 吗?
    猜你喜欢
    • 1970-01-01
    • 2022-06-17
    • 2017-05-29
    • 2016-02-16
    • 2017-02-20
    相关资源
    最近更新 更多