我正在尝试将 Web 服务从 Rails 6.0 升级到 Rails 6.1。运行时bundle install
,我看到一些我觉得奇怪的错误,因为依赖项的版本号要求看起来是兼容的,假设>=3.0.0
可以通过 version 来满足6.1
。抛出错误是因为在 Ruby 中,>=
有一些限制(即必须大于或等于....但不能大于....或不等于...)?
例如:
Bundler could not find compatible versions for gem "railties":
In Gemfile:
bootstrap-datepicker-rails was resolved to 1.9.0.1, which depends on
railties (>= 3.0.0)
coffee-rails was resolved to 5.0.0, which depends on
railties (>= 5.2.0)
dotenv-rails was resolved to 2.7.6, which depends on
railties (>= 3.2)
factory_bot_rails was resolved to 6.1.0, which depends on
railties (>= 5.0.0)
jquery-ui-rails was resolved to 6.0.1, which depends on
railties (>= 3.2.16)
pikaday-gem was resolved to 1.4.0, which depends on
railties (>= 3.1)
rails (~> 6.1) was resolved to 6.1.0, which depends on
railties (= 6.1.0)
rspec-rails was resolved to 4.0.2, which depends on
railties (>= 4.2.0)
在我看来,该要求是最严格的,但完全满足依赖于某个早期版本railties (= 6.1.0)
的所有其他依赖项。>=
为什么不bundle install
直接安装6.1.0
?
编辑:我尝试用这个最小的 Gemfile 重新创建问题,但失败了:
source "https://rubygems.org"
ruby "~> 2.6.6"
gem "rails", "~> 6.1"
gem "bootstrap-datepicker-rails"
gem "coffee-rails"
gem "dotenv-rails"
gem "factory_bot_rails"
gem "jquery-ui-rails"
gem "pikaday-gem"
gem "rspec-rails"
我也尝试了 Ruby 2.7 和 3.0,所有这些都成功安装。如果我再次看到该问题,我将使用更好的最小 Gemfile 再次更新此问题。在那之前,我们已经放弃了 Rails 6,因为 Apartment 不兼容。
编辑2:这是一个远非最小的gemfile,它重现了问题,但问题现在更加神秘。如果一个运行bundle install
,它会抛出像我的问题一样的错误,显示一组具有不兼容依赖版本的宝石。但是,如果我注释掉这个 gemfile 中的所有 gem,除了那些有假定冲突的 gem,那么它们安装得很好。换句话说,其他东西会导致打包程序抛出关于 gemset 不兼容的误导性错误。
这是您自己查看的 Gemfile:
source "https://rubygems.org"
ruby "~> 2.7.0"
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem "tzinfo-data"
gem "RedCloth", "~> 4.2.9"
gem "activerecord-import"
gem "apartment"
gem "attr_encrypted"
gem "carrierwave"
gem "email_validator"
gem "flutie"
gem "googlecharts", "~> 1.6.8"
gem "mini_magick"
gem "mysql2"
gem "neat"
gem "normalize-rails", "~> 3.0.0"
gem "omniauth-stripe-connect", "~> 2.9"
gem "pikaday-gem"
gem "pothoven-attachment_fu"
gem "prawn"
gem "prawn-table"
gem "puma_worker_killer"
gem "qbwc"
gem "rack-cors", require: "rack/cors"
gem "rack-mini-profiler", "~> 0.10.1"
gem "rack-rewrite", "~> 1.5"
gem "rails", "~> 6.1"
gem "recipient_interceptor"
gem "rollbar", "~> 2.27"
gem "simple_form"
gem "stripe", "~> 1.41"
gem "sucker_punch"
gem "will_paginate", "~> 3.1"
gem "xmlrpc"
gem "bootstrap-sass"
gem "coffee-rails"
gem "fog", require: "fog/aws/storage"
gem "fog-aws", require: false
gem "jbuilder", "~> 2.10"
gem "jquery-rails"
gem "jquery-ui-rails"
gem "memory_profiler"
gem "puma"
gem "rails-jquery-autocomplete"
gem "record_tag_helper"
gem "sass-rails"
gem "therubyracer", platforms: :ruby
gem "uglifier", ">= 1.3.0"
gem "bootstrap-datepicker-rails"
gem "american_date"
#Google App Engine
gem "appengine", "~> 0.5.0"
gem "stackdriver"
# speed boot time. Remove if Rails >=5.2 (comes with bootsnap https://guides.rubyonrails.org/5_2_release_notes.html)
gem 'bootsnap', require: false
group :production do
gem "newrelic_rpm"
gem "rack-timeout", "~> 0.4.2"
end
group :development do
gem "better_errors", "~> 2.0.0"
gem "binding_of_caller", "~> 0.8.0"
gem "bullet", "~> 6.1"
gem "pronto"
gem "pronto-brakeman", require: false
gem "pronto-eslint", require: false
gem "pronto-flay", require: false
gem "pronto-poper", require: false
gem "pronto-reek", require: false
gem "pronto-rubocop", require: false
end
group :development, :test do
gem "awesome_print"
gem "byebug"
gem "dotenv-rails"
gem "factory_bot_rails"
gem "ffaker", "~> 2.2"
gem "pry-byebug"
gem "pry-rails"
gem "railroady"
end
group :test do
gem "database_cleaner"
gem "formulaic"
gem "launchy"
gem "rspec-rails"
gem "shoulda-callback-matchers", "~> 1.1"
gem "shoulda-matchers", "~> 3.1", require: false
gem "simplecov", "~> 0.21.2"
gem "site_prism"
gem "timecop"
gem "webmock"
end