首页 > 解决方案 > Bundler 无法找到似乎在要求范围内的多个 gem 的兼容版本

问题描述

我正在尝试使用 gem spree,这取决于kaminari (~> 1.0.1). 在我的Gemfile.lock,我有kaminari (= 1.1.1)。这满足 的要求spree,因为它大于或等于最后一位。但是,当我尝试捆绑时出现此错误:

Bundler could not find compatible versions for gem "kaminari":
  In snapshot (Gemfile.lock):
    kaminari (= 1.1.1)

  In Gemfile:
    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      kaminari (>= 0.15)

    rails_admin (~> 1.3) was resolved to 1.3.0, which depends on
      kaminari (< 2.0, >= 0.14)

    spree (~> 3.5.0) was resolved to 3.5.0, which depends on
      spree_core (= 3.5.0) was resolved to 3.5.0, which depends on
        kaminari (~> 1.0.1)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

我不确定为什么 v1.1.1 不能满足所有相关宝石的要求,因为它似乎属于所有相关宝石的范围。我尝试运行bundle update,但随后我得到一长串不兼容的 gem,这些对我来说也没有任何意义,因为它们的要求似乎都在我的锁定文件中的版本范围内。例如,

Bundler could not find compatible versions for gem "activemodel":
  In Gemfile:
    carrierwave (~> 1.2) was resolved to 1.2.2, which depends on
      activemodel (>= 4.0.0)

    rails (~> 5.1.6) was resolved to 5.1.6, which depends on
      activemodel (= 5.1.6)

    web-console (>= 3.3.0) was resolved to 3.6.2, which depends on
      activemodel (>= 5.0)

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    annotate (~> 2.7) was resolved to 2.7.4, which depends on
      activerecord (< 6.0, >= 3.2)

    friendly_id (~> 5.2) was resolved to 5.2.4, which depends on
      activerecord (>= 4.0.0)

    rails (~> 5.1.6) was resolved to 5.1.6, which depends on
      activerecord (= 5.1.6)

    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      ransack (~> 1.3) was resolved to 1.8.8, which depends on
        activerecord (>= 3.0)

    spree_gateway (~> 3.3) was resolved to 3.3.3, which depends on
      spree_extension was resolved to 0.0.5, which depends on
        activerecord (>= 4.2)

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      arbre (>= 1.1.1) was resolved to 1.1.1, which depends on
        activesupport (>= 3.0.0)

    carrierwave (~> 1.2) was resolved to 1.2.2, which depends on
      activesupport (>= 4.0.0)

    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      inherited_resources (>= 1.7.0) was resolved to 1.8.0, which depends on
        has_scope (~> 0.6) was resolved to 0.7.2, which depends on
          activesupport (>= 4.1)

    jbuilder (~> 2.5) was resolved to 2.7.0, which depends on
      activesupport (>= 4.2.0)

    kaminari (~> 1.0.1) was resolved to 1.0.1, which depends on
      activesupport (>= 4.1.0)

    rails (~> 5.1.6) was resolved to 5.1.6, which depends on
      activesupport (= 5.1.6)

    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      ransack (~> 1.3) was resolved to 1.8.8, which depends on
        activesupport (>= 3.0)

    spring was resolved to 2.0.2, which depends on
      activesupport (>= 4.2)

    sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
      sprockets-rails (< 4.0, >= 2.0) was resolved to 3.2.1, which depends on
        activesupport (>= 4.0)

Bundler could not find compatible versions for gem "kaminari":
  In Gemfile:
    kaminari (~> 1.0.1)

    activeadmin (~> 1.3) was resolved to 1.3.0, which depends on
      kaminari (>= 0.15)

    rails_admin (~> 1.3) was resolved to 1.3.0, which depends on
      kaminari (< 2.0, >= 0.14)

Bundler could not find compatible versions for gem "spree_core":
  In Gemfile:
    spree (~> 3.5.0) was resolved to 3.5.0, which depends on
      spree_core (= 3.5.0)

    spree_gateway (~> 3.3) was resolved to 3.3.3, which depends on
      spree_core (< 4.0, >= 3.1.0)

这些错误引发了一系列全新的问题,因为我没有看到任何 gem 的版本有任何冲突。

对于activemodel,为什么不能使用 5.1.6?这不满足所有要求吗?

对于activerecord,为什么不能使用 5.1.6?这不满足所有要求吗?

对于activesupport,为什么不能使用 5.1.6?这不满足所有要求吗?

对于kaminari,为什么不能使用 1.0.1?这不满足所有要求吗?

对于spree_core,为什么不能使用 3.5.0?这不满足所有要求吗?

如何解决这些问题?我已经尝试bundle update为所有宝石和单个宝石运行,但无论哪种方式我都会收到相同的错误消息。

标签: ruby-on-railsrubyrubygemscompatibility

解决方案


这满足了狂欢的要求,因为它大于或等于最后一个数字。

这不太正确,Bundler 的 Gemfile状态的文档:

说明符~>具有特殊含义,最好通过示例来说明。~> 2.0.3>= 2.0.3和相同< 2.1

因此,在您的情况下,对于 kaminari,~> 1.0.1意味着'>= 1.0.1'and '< 1.1',(显然)1.1.1不满足。

至于其他人,在我看来一切可以正常工作,尽管我注意到很多失败的人需要与狂欢或雷神有关,所以也许修复一个会对那些人有所帮助。其他的也可能(也许)是级联错误,有点像一个地方缺少括号或逗号会导致整个文件出现语法错误,也许只有一个错误会级联到包的其余部分,我会小心的Kaminari 然后看看你还剩下什么。


推荐阅读