【问题标题】:Bundler could not find compatible versions for gem "railties" when using BitPay and Spree CommerceBundler 在使用 BitPay 和 Spree Commerce 时找不到 gem "railties" 的兼容版本
【发布时间】:2025-12-25 15:05:16
【问题描述】:

当我尝试时

bundle install

我得到错误:

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    spree_bitpay (>= 0) ruby depends on
      spree_auth_devise (>= 0) ruby depends on
        devise (~> 2.0.4) ruby depends on
          railties (~> 3.1) ruby

    spree_bitpay (>= 0) ruby depends on
      rails (= 4.0.9) ruby depends on
        railties (4.0.9)

我尝试了我的 Gemfile 的 2 个版本,一个是标准 Gemfile 加上 bitpay 行,一个是我将所有其他 gem 注释掉,只有 bitpay 行,两者都不起作用。

宝石文件:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.9'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# 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'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

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

# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'spree_bitpay', :git => 'https://github.com/bitpay/spree-bitpay.git'

我是 Ruby 和 Gemfiles 等的新手。谢谢 =)

做'gem list'我可以看到我有两个必需的版本: railties (4.1.8, 4.0.12, 4.0.9, 3.1.0)

【问题讨论】:

  • 删除Gemfile中需要的版本,只留下gem 'rails'并再次运行bundle install
  • 错误仍然显示:Bundler 找不到 gem "railties" 的兼容版本:在 Gemfile:spree_bitpay (>= 0) ruby​​ 依赖于 spree_auth_devise (>= 0) ruby​​ 依赖于 devise (~> 2.0 .4) ruby​​ 依赖于 railties (~> 3.1) ruby​​ spree_bitpay (>= 0) ruby​​ 依赖于 rails (= 4.0.9) ruby​​ 依赖于 railties (4.0.9)
  • 您是否已经尝试过运行bundle update
  • 是:包更新更新github.com/bitpay/spree-bitpay.git 正在从rubygems.org 获取gem 元数据............正在从rubygems.org 获取其他元数据.. 解决依赖关系... Bundler 找不到gem "railties" 的兼容版本:在 Gemfile 中:spree_bitpay (>= 0) ruby​​ 依赖于 spree_auth_devise (>= 0) ruby​​ 依赖于 devise (~> 2.0.4) ruby​​ 依赖于 railties (~> 3.1) ruby​​ spree_bitpay (> = 0) ruby​​ 依赖于 rails (= 4.0.9) ruby​​ 依赖于 railties (4.0.9)
  • spree_bitpay 依赖于 rails 3.1 - 3.2。你暂时不能使用 rails 4.x。

标签: ruby-on-rails ruby spree


【解决方案1】:

问题的存在是因为 spree-bitpay 的 gemspec 只指定了“spree_auth_devise”,而他们在Gemfile 中指定的版本实际上是这样的:

gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-2-stable'

我怀疑当你 bundle install 时,它正在尝试使用 spree_auth_devise 的 Rubygems.org 版本,该版本自 2012 年以来一直没有更新(似乎大约是 Rails 3 的时间)。

解决您的问题的方法是将上述行添加到您的 Gemfile 中。

此外,您应该向 spree-bitpay 的维护者提出这个问题。请向他们提出问题,我相信他们会很感激的!

【讨论】:

  • 确实,我们将不胜感激。