gpt4 book ai didi

ruby-on-rails - 如何解决错误 "bundler could not find compatible version for gem X"

转载 作者:数据小太阳 更新时间:2023-10-29 08:43:13 25 4
gpt4 key购买 nike

我正在尝试为我的项目设置 docker。我已经尝试安装 actionpack 5.0.2,但它对我没有任何好处。我正在按照有关如何设置的教程进行操作,因此我认为存在版本问题。当我运行 docker-compose up 时,这是我得到的:

Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
rails (~> 5.0.2) ruby depends on
actionpack (= 5.0.2) ruby

actionpack (>= 5.1.1, ~> 5.1) ruby

这是我的 Gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'devise'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', :platforms => :ruby

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'unicorn', '~> 4.9'
gem 'pg', '~> 0.18.3'
gem 'sidekiq', '~> 4.0.1'
gem 'redis-rails', '~> 4.0.0'
gem 'actionpack', '~> 5.1', '>= 5.1.1'

编辑:尝试从 gemfile 中完全删除 gem actionpack,导致 docker-compose up 出现新问题:

Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
rails (~> 5.0.2) ruby depends on
actioncable (= 5.0.2) ruby depends on
actionpack (= 5.0.2) ruby

rails (~> 5.0.2) ruby depends on
actioncable (= 5.0.2) ruby depends on
actionpack (= 5.0.2) ruby

rails (~> 5.0.2) ruby depends on
actioncable (= 5.0.2) ruby depends on
actionpack (= 5.0.2) ruby

rails (~> 5.0.2) ruby depends on
actioncable (= 5.0.2) ruby depends on
actionpack (= 5.0.2) ruby

redis-rails (~> 4.0.0) ruby depends on
redis-actionpack (~> 4) ruby depends on
actionpack (~> 4) ruby
ERROR: Service 'drkiq' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 6

最佳答案

Gemfile 中的这两行导致了依赖冲突:

gem 'rails', '~> 5.0.2'
gem 'actionpack', '~> 5.1', '>= 5.1.1'

~> 5.0.2 表示“大于 5.0.2 且小于 5.1.0”。

'~> 5.1',​​ '>= 5.1.1' 表示“大于5.1.1且小于6.0.0 ”。

因此存在冲突,Bundler无法解决。您需要升级 rails 或降级 actionpack

最简单的解决方案可能是从 Gemfile删除 actionpack,因为您根本不需要指定它。 actionpackrails 的依赖项,因此无论如何都会安装它。

我还建议您删除 rails 上的 '~> 5.0.2' 版本限制,除非您有充分的理由锁定版本号。

关于您的第二个错误的更新:

这个错误和上面的很相似;这是不言自明的。

rails (~> 5.0.2) ruby depends on
[...]
actionpack (= 5.0.2) ruby

redis-rails (~> 4.0.0) ruby depends on
[...]
actionpack (~> 4) ruby

就像上面一样,您有一个 gem 依赖于 actionpack 版本 v4.x.x,另一个 gem 依赖于 actionpack v5.0.2

您需要以某种方式更新/放宽您的 Gemfile 中的版本限制。例如,您可以这样写:

gem 'redis-rails', '~> 5.0'

关于ruby-on-rails - 如何解决错误 "bundler could not find compatible version for gem X",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44198818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com