Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

ruby on rails - Does Gemfile `>=` allow for newer major versions to satisfy dendency?

I'm trying to upgrade a web service from Rails 6.0 to Rails 6.1. When running bundle install, I'm seeing some errors which I find odd since the version number requirements of the dependencies appear compatible, assuming >=3.0.0 can be satisfied by version 6.1. Is the error being thrown because in Ruby, >= has some limitations (ie must be greater than or equal to....but not that greater than....or not that equal...)?

For example:

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)

To my mind, the railties (= 6.1.0) requirement is most restrictive, yet fully satisfies all the other dependencies which rely on >= some earlier version. Why doesn't bundle install just install 6.1.0?

EDIT: I Attempted to recreate the issue with this minimal Gemfile and failed:

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"

I tried with Ruby 2.7 and 3.0 too, all of which succeeded to install. If I see the problem again, I'll update this question again with a better minimal Gemfile. Until then, we've abandoned Rails 6 since Apartment is not compatible.

EDIT 2: Here's a far-from-minimal gemfile which reproduces the problem, but the issue is now more mysterious. If one runs bundle install, it will throw errors like the one in my question, showing sets of gems with incompatible dependency versions. But, if i comment out all the gems in this gemfile except those ones with the supposed conflicts, then they install just fine. In other words, something else is caused bundler to throw misleading errors about gemset incompatibility.

Here's the Gemfile to see for yourself:

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
question from:https://stackoverflow.com/questions/66055375/does-gemfile-allow-for-newer-major-versions-to-satisfy-dendency

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...