Ruby on Rails - Bundler找不到gem“activerecord”的兼容版本

时间:2014-09-03 13:56:15

标签: ruby-on-rails gem bundler

我安装了Rails 2.3.8以维护客户端的遗留代码。问题是我无法运行bundler install,因为它在产生以下错误后失败:

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    rails (= 2.3.8) ruby depends on
      activerecord (= 2.3.8) ruby

    activerecord (2.3.11)

我的Gmefile是

source :gemcutter

# == Application Gems
gem "rails", "2.3.8"
gem "activesupport"
gem "mysql", "2.8.1"
gem "devise", "1.0.8"
gem "inherited_resources", "1.0.6"
gem "will_paginate", "2.3.14"
gem "canable", "0.1.1", :require => 'canable'
gem "aasm", "2.1.5", :require => "aasm"
gem "fastercsv", "1.5.3", :require => 'fastercsv'
gem "jnunemaker-validatable", :require => 'validatable'
gem "thinking-sphinx", "1.3.18"
gem "delayed_job", "2.1.0.pre"
gem "ts-delayed-delta", "1.1.0", :require => "thinking_sphinx/deltas/delayed_delta"
gem "erubis"
gem "cloudfiles"
gem 'hoptoad_notifier'
gem 'aws-s3'
gem 'json'
gem 'cocaine'
gem 'fog', '~> 0.9.0'

# requires exiftool (command line utility) to be installed!
#  http://www.sno.phy.queensu.ca/~phil/exiftool/install.html
gem "mini_exiftool", "2.4.2"
gem "rack-killswitch"
gem "carmen"
gem "rest-client"

# == Deployment Gems
gem "capistrano"
gem "capistrano-ext"

# Visual email testing in the browser
gem "mail_view", :group => :development

# == Test Gems
group :test do
  gem "shoulda", "2.11.1"
  gem "machinist", "1.0.3"
  gem "faker", "0.3.1"
  gem "mocha", "0.9.8"
  gem "timecop", "0.3.4"
  gem "cucumber", "0.8.5"
  gem "cucumber-rails", "0.3.2"
  gem "webrat" # needed for cucumber
  gem "database_cleaner", "0.5.0" # needed for cucumber
  gem "sinatra", "1.0"
  gem "rack-contrib"
  gem "artifice"
end

我添加了gem "activerecord", "2.3.8"没有成功,因为它说,捆绑包已锁定到2.3.11。

是否有人能够。

2 个答案:

答案 0 :(得分:0)

尝试

bundle update activerecord

应该处理活动记录的特定版本

可能性是其他宝石中的一个锁定了你的Rails 2.3.11(ActiveRecord 2.3.11)。您可以看到什么取决于Gemfile.lock中的内容。

另一种选择是删除Gemfile.lock并再次运行bundle。

答案 1 :(得分:0)

我遇到了类似的错误,希望它对其他人有帮助

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    jsonb_accessor (~> 1.0.0) was resolved to 1.0.0, which depends on
      activerecord (>= 5.0)

    kaminari (= 1.1.1) was resolved to 1.1.1, which depends on
      kaminari-activerecord (= 1.1.1) was resolved to 1.1.1, which depends on
        activerecord

    paper_trail (~> 8) was resolved to 8.1.2, which depends on
      activerecord (>= 4.2, < 5.2)

    rails (~> 5.2) was resolved to 5.2.1.rc1, which depends on
      activerecord (= 5.2.1.rc1)

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

    api_blueprint was resolved to 0.1.2, which depends on
      rails

就我而言,我正在尝试更新rails。解决的办法是找出对activerecord <5.2(在这种情况下为paper_trail)具有依赖性的gem。解决方案是将PaperTrail降级到5.2版,此后我就可以将Rails更新到5.2版以上。