找不到兼容的gem“rack”版本

时间:2017-02-25 22:21:06

标签: ruby-on-rails ruby rack rails-upgrade

我正在尝试将我的应用更新为Rails 5.0.1。尝试运行bundle update后,会出现以下错误,但没有机架宝石。

我该如何解决这个问题?

错误:

 Bundler could not find compatible versions for gem "rack":
      In Gemfile:
        rails (= 5.0.1) x86-mingw32 was resolved to 5.0.1, which depends on
          actionpack (= 5.0.1) x86-mingw32 was resolved to 5.0.1, which depends on
            rack (~> 2.0)

        rails (= 5.0.1) x86-mingw32 was resolved to 5.0.1, which depends on
          actionpack (= 5.0.1) x86-mingw32 was resolved to 5.0.1, which depends on
            rack (~> 2.0) x86-mingw32

        sprockets (= 2.11.3) was resolved to 2.11.3, which depends on
          rack (~> 1.0)

        sprockets (= 2.11.3) was resolved to 2.11.3, which depends on
          rack (~> 1.0) x86-mingw32

的Gemfile:

source 'http://rubygems.org'
ruby '2.4.0'  # '1.9.3'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '5.0.1'#'4.2.6'
#gem 'pg', '0.15.1'
gem 'mysql2', '0.4.5'#'0.4.4'
gem 'bootstrap-sass', '2.3.2.0'#'3.3.6'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'geocoder', '1.3.7'
gem 'nested_form', '0.3.2'
gem 'utf8-cleaner', '0.2.4'
gem 'sprockets', '2.11.3' #2.11.3
gem 'json', '1.8.6'#'1.8.3'
gem 'ffi'
gem 'iconv', '1.0.4'

gem 'chosen-rails', '1.5.2'
gem 'compass-rails', github: 'Compass/compass-rails'

# For image uploads
gem 'carrierwave', '0.11.2'

# For uploading CSV
gem 'roo', '2.4.0'

# DataTables
gem 'jquery-datatables-rails', '3.4.0' #  git: 'git://github.com/rweng/jquery-datatables-rails.git'
gem 'jquery-ui-rails', '5.0.5'

# Editing in line:
gem 'best_in_place', '3.1.0'

# Passing data from controller to coffeescript
gem 'gon', '6.0.1'
#gem 'jquery-turbolinks' '2.1.0'

# For searching and webservice queries-NO LONGER USED
#gem 'sunspot_rails', '2.1.0'
#gem 'sunspot_solr', '2.1.0'
gem 'progress_bar', '1.0.5'

gem 'responders', '2.2.0'

# Calendar Date and Validation
gem 'bootstrap-datepicker-rails'

# For Google Maps overlays
gem 'gmaps4rails', '~> 2.1.2'
gem 'underscore-rails', '~> 1.8.3'

group :development, :test do
  gem 'rspec-rails', '3.4.2'
  gem 'guard-rspec', '4.7.2'
  gem 'spork-rails', '4.0.0'
  gem 'childprocess', '0.5.9'
  gem 'guard-spork', '2.1.0'
end

group :test do
  gem 'selenium-webdriver', '2.53.3'
  gem 'capybara', '2.7.1'
  gem 'factory_girl_rails', '4.7.0'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.5.0'

group :doc do
  gem 'sdoc', '0.4.1', require: false
end

gem 'rails_12factor', '0.0.3'

1 个答案:

答案 0 :(得分:3)

全部在错误消息中:

您在Gemfile中指定了与rack gem存在冲突依赖关系的宝石。 Rails 5(通过actionpack)需要机架2,您的固定版sprockets需要机架1。

因此,您有两种选择:

  1. 您可以将您的铁路需求降级为Rails 4,然后依赖于机架1.为此,请将您指定Gemfile的{​​{1}}中的行替换为:

    rails
  2. 或者(这可能是您想要的选项),您可以升级您正在使用的链轮版本。为此,您只需将显式固定版本移至gem 'rails', '< 5' 中的sprockets即可。由于Rails已经依赖于合适的链轮版本,因此您无需将其指定为自己的版本。通常,为了使用带有Rails 5的链轮,至少需要链轮3.3.5。