我的项目的当前状态是使用rails 4.2.11和ruby2.3.0。我希望开始使用rails 5.0并保留ruby版本,因为据我所知,rails 5.0与ruby >2.2.2兼容。但是,在执行bundle install命令之后,引发了一些我不理解的错误。例如:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (= 5.0)
dropzonejs-rails was resolved to 0.8.5, which depends on
rails (> 3.1)我觉得这种行为有点奇怪,因为rails版本超过3.1,所以在我看来,这个错误不应该存在。还有一个例子:
Bundler could not find compatible versions for gem "spring":
In Gemfile:
spring
spring-commands-rspec was resolved to 1.0.4, which depends on
spring (>= 0.9.1)该项目的春季版本为2.0.2。
请你解释一下这个错误是什么意思好吗?
更新
以下是我收到的错误的完整列表:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
omniauth-rails_csrf_protection (~> 0.1) was resolved to 0.1.2, which depends on
actionpack (>= 4.2)
rails (= 5.0) was resolved to 5.0.0, which depends on
actionpack (= 5.0.0)
rspec-rails (~> 3.8) was resolved to 3.9.1, which depends on
actionpack (>= 3.0)
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
json_on_rails (~> 0.2.0) was resolved to 0.2.0, which depends on
activerecord (~> 4.0)
rails (= 5.0) was resolved to 5.0.0, which depends on
activerecord (= 5.0.0)
Bundler could not find compatible versions for gem "byebug":
In Gemfile:
byebug
pry-byebug was resolved to 3.7.0, which depends on
byebug (~> 11.0)
Bundler could not find compatible versions for gem "mysql2":
In Gemfile:
mysql2 (~> 0.4.10)
json_on_rails (~> 0.2.0) was resolved to 0.2.0, which depends on
mysql2 (~> 0.3)
Bundler could not find compatible versions for gem "prawn":
In Gemfile:
prawn
prawn-table was resolved to 0.2.2, which depends on
prawn (< 3.0.0, >= 1.3.0)
Bundler could not find compatible versions for gem "pry":
In Gemfile:
pry (~> 0.10.3)
pry-byebug was resolved to 3.7.0, which depends on
pry (~> 0.10)
pry-doc was resolved to 0.12.0, which depends on
pry (~> 0.9)
pry-stack_explorer was resolved to 0.4.9.3, which depends on
pry (>= 0.9.11)
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (= 5.0)
dropzonejs-rails was resolved to 0.8.5, which depends on
rails (> 3.1)
Bundler could not find compatible versions for gem "ruby":
In Gemfile:
ruby
active_model_serializers (~> 0.9.4) was resolved to 0.9.8, which depends on
ruby (>= 1.9.3)
apnotic was resolved to 1.6.1, which depends on
ruby (>= 2.1.0)
audited (~> 4.9) was resolved to 4.10.0, which depends on
ruby (>= 2.3.0)
chartkick was resolved to 4.0.5, which depends on
ruby (>= 2.6)
faker was resolved to 2.12.0, which depends on
ruby (>= 2.3)
jwt was resolved to 2.2.3, which depends on
ruby (>= 2.1)
newrelic_rpm was resolved to 7.2.0, which depends on
ruby (>= 2.0.0)
puma was resolved to 5.4.0, which depends on
ruby (>= 2.2)
rails (= 5.0) was resolved to 5.0.0, which depends on
ruby (>= 2.2.2)
signalwire was resolved to 2.3.4, which depends on
ruby (>= 2.0)
thin was resolved to 1.8.1, which depends on
ruby (>= 1.8.5)
tzinfo-data was resolved to 1.2021.1, which depends on
ruby (>= 1.8.7)
Bundler could not find compatible versions for gem "spring":
In Gemfile:
spring
spring-commands-rspec was resolved to 1.0.4, which depends on
spring (>= 0.9.1)`这是Gemfile的内容:
# frozen_string_literal: true
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0'
# db connectivity
gem 'mysql2', '~> 0.4.10'
gem "json_on_rails", "~> 0.2.0"
# web server
gem 'puma'
# for the JSON API
gem 'active_model_serializers', '~> 0.9.4'
# Audited is an ORM extension that logs all changes to your models.
gem "audited", "~> 4.9"
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# HAML templating engine
gem 'haml'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'therubyracer', platform: :ruby
gem 'uglifier', '>= 4.0.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'
# CORS
gem 'rack-cors', require: 'rack/cors'
# Use Unicorn as the app server
# gem 'unicorn'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
gem 'momentjs-rails', '>= 2.9.0'
gem 'fcm'
gem 'apnotic'
gem 'aws-sdk', '~> 2'
gem 'dropzonejs-rails'
gem 'paperclip'
gem 'phonelib'
gem 'prawn'
gem 'prawn-table'
gem "daemons"
gem 'chartkick'
gem 'dentaku', '~> 3.3'
# error reporting
gem "rollbar"
# cron job
gem 'whenever'
# Event machine
gem "em-eventsource"
# Delayed job related gems
gem 'delayed_job_active_record'
gem "delayed_job_web"
gem 'kaminari'
gem 'stripe'
gem 'geocoder'
gem "signalwire"
gem 'http'
#shortened URLs
gem 'shortener'
gem 'rmagick'
gem 'jwt'
gem 'shoryuken'
gem 'omniauth-auth0', '~> 2.2'
gem 'omniauth-rails_csrf_protection', '~> 0.1'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# An IRB alternative and runtime developer console (http://pryrepl.org)
gem 'pry', '~> 0.10.3'
# Fast debugging with Pry. (https://github.com/deivid-rodriguez/pry-byebug)
gem 'pry-byebug'
# Provides YARD and extended documentation support for Pry (https://github.com/pry/pry-doc)
gem 'pry-doc'
# Connect to Pry remotely (http://github.com/Mon-Ouie/pry-remote)
gem 'pry-remote'
# Walk the stack in a Pry session (https://github.com/pry/pry-stack_explorer)
gem 'pry-stack_explorer'
# A thin and fast web server (http://code.macournoyer.com/thin)
gem 'thin'
gem 'capistrano-npm'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano3-puma'
gem 'capistrano3-delayed-job', '~> 1.0'
gem 'rspec-rails', '~> 3.8'
gem 'database_cleaner'
gem "factory_bot_rails"
# fake data for tests
gem 'faker'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'tzinfo-data'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-commands-rspec'
gem 'rb-readline'
end
group :production do
gem 'newrelic_rpm'
gem 'rails_12factor' # need for hcb
end发布于 2021-08-16 14:26:49
正如您最初描述的那样,我对这个问题感到惊讶,“我发现这个行为有点奇怪,因为rails版本超过3.1,所以在我看来,这个错误不应该存在。”我相信你,但我也觉得很奇怪。
但是,我在错误输出中看到了一些明显的问题。根据我的经验,当你有一个问题时,你不理解和发现另一个问题,你知道如何解决,修复你能解决的问题,或者在你遇到的问题上取得进展。
你有很多旋转-大于(~>),这被称为邦德勒的悲观运算符。意思是“等于或大于,但仅等于除最后一个数字外的所有数字”。
rspec-rails (~> 3.8) was resolved to 3.9.1, which depends on
actionpack (>= 3.0)
json_on_rails (~> 0.2.0) was resolved to 0.2.0, which depends on
activerecord (~> 4.0)
pry-byebug was resolved to 3.7.0, which depends on
byebug (~> 11.0)
json_on_rails (~> 0.2.0) was resolved to 0.2.0, which depends on
mysql2 (~> 0.3)您还遇到了一个问题,因为您正在使用chartkick版本,该版本依赖于更高级别的红宝石。
chartkick was resolved to 4.0.5, which depends on
ruby (>= 2.6)一种激进的方法是删除您的Gemfile.lock,执行一个bundle install,然后您应该有较少的错误。这些错误会使您在Gemfile中设置一个较旧的gem版本。
一种保守的方法是,如果您可以恢复您的Gemfile.lock,它在您更新rails之前就可以使用,而不是bundle install。
bundle update rspec-rails json_on_rails pry-byebug json_on_rails更新Gemfile中的rails将迫使bundle update更新所有rails宝石,命令行中的gems列表将告诉bundler更新这些内容,但希望它不会更新任何不需要更新的内容(比如chartkick,它引入了ruby版本的一个问题)。
这将需要一些尝试和错误,但您应该能够修复一些错误消息。在这样做之后,看看是否还有dropzonejs-rails宝石,因为这个问题可能会消失。
好运,
发布于 2021-08-15 17:43:59
您的bundler版本可以是更早的版本。您应该卸载bundler并重新安装bundler。
gem卸载bundler宝石安装绑定程序
如果这行不通的话。使用以下命令gem install :2.0.0.pre.3
https://stackoverflow.com/questions/68793271
复制相似问题