Bundler 无法为似乎符合要求范围的多个 gem 找到兼容版本

Bundler could not find compatible versions for multiple gems that seem to fall within range of requirements

我正在尝试使用 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 不满足所有相关 gem 的要求,因为它似乎在所有相关 gem 的范围内.我尝试了 运行 bundle update,但后来我得到了一长串 gem 不兼容,其中 none 对我来说也很有意义,因为它们的要求似乎都在范围内我的锁定文件中的版本。例如,

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?这还不满足所有要求吗?

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

This satisfies the requirement for spree, since it's greater than or equal to the last digit.

这不太正确,docs for Bundler's Gemfile 状态:

The specifier ~> has a special meaning, best shown by example. ~> 2.0.3 is identical to >= 2.0.3 and < 2.1.

所以在你的情况下,对于 kaminari,~> 1.0.1 将意味着 '>= 1.0.1''< 1.1',这(显然)1.1.1 不满足。

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

您是否验证过您尝试安装的spree 版本是否与更高版本的kaminari 兼容?尝试将 kaminari gem 降级到“~> 1.0.1”,看看是否有帮助。

如果这不起作用,那么另一个建议是 运行 "bundle update" 在您当前的 gem 集 "before" 中添加 "spree" Gemfile 以确保您正在使用当前安装的所有最新版本 gems.