【问题标题】:Bundler errors when bundling w/Rails 5.0.6 after upgrading from 4.2从 4.2 升级后与 Rails 5.0.6 捆绑时出现捆绑器错误
【发布时间】:2020-10-26 15:54:43
【问题描述】:

尝试将 Ruby 2.2/Rails 4.2 升级到 Rails 5.0.6(已经放弃了 5.0.7.2,因为它似乎需要 Zeitwerk,它需要 Ruby >= 2.4.4)。问题是我从 bundler 中收到了关于 25 个 gem 的错误消息,看起来类似于:

Bundler could not find compatible versions for gem "actionmailer":
  In Gemfile:
    premailer-rails was resolved to 1.11.1, which depends on
      actionmailer (>= 3)

    rails (= 5.0.6) was resolved to 5.0.6, which depends on
      actionmailer (= 5.0.6)

现在,我的 gem 文件中有 gem "rails", '5.0.6' 并且没有 actionmailer 列表。 actionmailer 5.0.6 似乎可以满足这两个要求,那么为什么捆绑器会抱怨(我确实在 bundle update 命令中列出了 actionmailer)?更重要的是,我能做些什么来解决这个问题?

在之前的 Rails 升级中,我删除了 gemfile.lock 并执行了 bundle install 并最终使其正常工作。所以我尝试了这个升级,只是得到了相同的错误集。我也尝试了bundle update --all 并得到了同样的错误。

这是 Gemfile:

source 'http://rubygems.org'

ruby '2.2.10'

gem 'rails', '5.0.6'
gem 'railties', '5.0.6'

gem 'rake', '~> 10.4.2'             # Version added when moving to RSpec 2.99
gem 'rack-cache', '1.5.1'           # Added for 'rake', '~>10.4.2'

gem 'pg', '~> 0.15.0'               # AR on 4.2 requires 0.15
# Note: must edit database.yml to include "host: local" and remove the username put there by "rails new <app> -db postgresql"

gem 'puma', '3.11.4'

gem 'rails_12factor', group: :production

gem 'sidekiq', '2.13.1', path: 'vendor/sidekiq/sidekiq-2.13.1'
gem 'sidekiq-pro', '1.2.2', path: 'vendor/sidekiq-pro/sidekiq-pro-1.2.2'
gem 'celluloid', '0.15.2'           # Added when moving to Rails 4.0.13
gem 'redis', '3.3.3'                # Added version when moving to Rails 4.0.13
gem 'redis-namespace', '1.5.2'      # Added version when moving to Rails 4.0.13
gem 'connection_pool', '2.2.0'      # Added when moving to Rails 4.0.13
# Need the following gems for sidekiq/web
gem 'slim'
# if you require 'sinatra' you get the DSL extended to Object
gem 'sinatra', :require => nil

gem 'minitest', '5.9.1'             # Added when moving to Rails 4.1.16
gem 'jeff', '~>1.2'                 # Added when moving to Rails 4.1.16
gem 'excon', '0.22.1'               # Added when moving to Rails 4.1.16
gem 'raindrops', '0.19.1'           # Added when moving to Rails 4.1.16

gem 'sprockets-rails', '~> 2.0'
gem 'sprockets', '~> 2.8'


gem 'a2z', '0.1.2'

gem 'public_suffix', '1.5.3'        # Added when moving to Rails 4.0.13
gem 'hitimes', '1.2.2'              # Added when moving to Rails 4.0.13
gem 'ffi', '1.9.6'                  # Added when moving to Rails 4.0.13
gem 'faraday', '0.8.9'              # Added when moving to Rails 4.0.13
gem 'net-http-persistent', '2.5.2'  # Added when moving to Rails 4.0.13

gem 'platform-api', '2.1.0'         # Added version when moving to Rails 4.0.13

gem 'json', '1.8.6'                 # Added version when moving to Rails 4.0.13

gem 'lograge'

gem 'oauth2', '0.9.4'
gem 'omniauth', '1.2.1'
gem 'omniauth-oauth2', '1.1.2'
gem 'omniauth-google-oauth2', '0.2.4'    # Google OAuth-2 Login via OmniAuth
gem 'jwt', '1.0.0'                  # Added when moving to Rails 4.0.13

gem 'premailer-rails'     # Converts CSS styles to inline styles, creates plain-text email from HTML email
gem 'premailer', '1.8.4'            # Added version when moving to Rails 4.0.13
gem 'psych', '2.0.5'

gem 'stripe', '1.25.0', path: 'vendor/stripe/stripe-ruby-1.25.0'

gem 'sass-rails', '~> 5.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'uglifier', '>= 1.3.0'

gem 'mechanize', '2.7.2'            # Added version when moving to Rails 4.0.13
gem 'nokogiri', '1.6.7.2'           # Added version when moving to Rails 4.0.13
gem 'spreadsheet', '> 0.9.0'
gem 'roo', '2.5.1'                  # Added version when moving to Rails 4.0.13
gem 'roo-xls'
gem 'xml-simple'
gem 'rubyzip', '1.2.2'              # Added version when moving to Rails 4.0.13
gem 'scbi_multi_gz_reader'

gem 'rmagick', '2.15.4'             # Added version when moving to Rails 4.0.13

gem 'jquery-rails'
gem 'jquery-ui-rails'

# To use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.0'

gem 'will_paginate', '~> 3.0.0'

gem 'geoip'

gem 'byebug', '~> 10.0.0'

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring', '2.0.2'
end

group :test do
  gem 'rspec-rails', '~> 3.1'
  gem 'faker', '~> 0.3.1'
  gem 'shoulda-matchers', '2.8.0'               # Added version when moving to Rails 4.0.13
  gem 'capybara'                                # Switched from Webrat to Capybara w/ Rails 4.2
  gem 'factory_girl_rails', '4.7.0'             # Added version when moving to Rails 4.0.13
  gem 'timecop'
end

gem 'htmlentities'
gem 'retina_tag'

gem 'useragent'

【问题讨论】:

  • 两个问题:你运行的是哪个版本的 bundler,你能发布你的 Gemfile 吗?
  • 捆绑器版本 1.17.3
  • 顺便说一句,我可以通过删除/更改某些 gem 的版本来解决 Gemfile 的问题,但现在我专注于第一个错误(因为大多数错误看起来像那,如果我正确地阅读了消息,那没有意义 ">= 3.0" 和 "= 5.0.6" 应该是兼容的依赖项)。

标签: ruby-on-rails rubygems ruby-on-rails-5 bundler


【解决方案1】:

这是我解决这个问题的方法。

  1. 从 Gemfile 中删除所有 gem(Ruby 和 Rails 除外)的版本。
  2. 删除 Gemfile.lock
  3. 捆绑安装

就我而言,我在带有原生扩展的 gem 上遇到了一些构建错误。大多数都与 CLANG(Mac OS X C 编译器)的更改有关,需要我将 -- --with-cflags="-Wno-error=implicit-function-declaration" 添加到 gem 安装中。

【讨论】:

    猜你喜欢
    • 2021-11-18
    • 1970-01-01
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 2015-01-30
    • 2023-03-05
    相关资源
    最近更新 更多