Ruby-on-rails Bundler 找不到 gem 的兼容版本,正在更新 Rails 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8858706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:37:45  来源:igfitidea点击:

Bundler could not find compatible versions for gem, updating Rails app

ruby-on-railsrubyruby-1.9.3ruby-on-rails-3.2

提问by rudolph9

After createing a brand new rails app Following the official rails blog post, attempting to convert apps to rails 3.2.0.rc2 yields the following

在创建全新的 rails 应用程序之后,按照官方的 rails 博客文章,尝试将应用程序转换为 rails 3.2.0.rc2 会产生以下结果

Updated Gemfile to depend on rails ~> 3.2.0.rc2
    gem 'rails', '~>3.2.0.rc2'
Updated Gemfile to depend on sass-rails ~> 3.2.3
    gem 'sass-rails',   '~> 3.2.3'

$ bundle install
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "activesupport":
  In snapshot (Gemfile.lock):
    activesupport (3.1.1)

  In Gemfile:
    rails (~> 3.2.0.rc2) ruby depends on
      activesupport (= 3.2.0.rc2) ruby

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

$bundle update
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    coffee-rails (~> 3.1.1) ruby depends on
      railties (~> 3.1.0) ruby

    rails (~> 3.2.0.rc2) ruby depends on
      railties (3.2.0.rc2)

What exactly is the issue?

究竟是什么问题?

System Specs:

系统规格:

Mac OS 10.7.2, Xcode 4.2.1, rvm 1.10.1 using ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

Mac OS 10.7.2、Xcode 4.2.1、rvm 1.10.1 使用 ruby​​ 1.9.3p0(2011-10-30 修订版 33570)[x86_64-darwin11.2.0]

回答by rudolph9

I solved it by deleting the lock rm Gemfile.lockand again running bundle install:

我通过删除锁rm Gemfile.lock并再次运行来解决它bundle install

$ rm Gemfile.lock
$ bundle install
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.0.4) 
Using activesupport (3.2.0.rc2) 
Using builder (3.0.0) 
Using activemodel (3.2.0.rc2) 
Using erubis (2.7.0) 
Using journey (1.0.0) 
Using rack (1.4.0) 
Using rack-cache (1.1) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.0.rc2) 
Using mime-types (1.17.2) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.3.0) 
Using actionmailer (3.2.0.rc2) 
Using arel (3.0.0) 
Using tzinfo (0.3.31) 
Using activerecord (3.2.0.rc2) 
Using activeresource (3.2.0.rc2) 
Using bundler (1.0.21) 
Using coffee-script-source (1.2.0) 
Using execjs (1.2.13) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.4) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.0.rc2) 
Using coffee-rails (3.2.1) 
Using jquery-rails (2.0.0) 
Using rails (3.2.0.rc2) 
Using sass (3.1.12) 
Using sass-rails (3.2.3) 
Using sqlite3 (1.3.5) 
Using uglifier (1.2.2) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

This is a pretty brute force way of fixing the issue. If this is an established project, you may run into other issues after deleting the Gemfile.lockas the dependency versions are no longer locked. However, if this is a new project it's unlikely you will run into problems taking this approach.

这是解决问题的一种非常强力的方法。如果这是一个已建立的项目,则删除后可能会遇到其他问题,Gemfile.lock因为不再锁定依赖项版本。但是,如果这是一个新项目,则采用这种方法不太可能遇到问题。

回答by Frederick Cheung

As well as sass-rails, you need to bump the version of coffee-railsyou depend on too (3.2.1 ought to do it)

此外sass-rails,您还需要提高coffee-rails您所依赖的版本(3.2.1 应该这样做)

回答by Feuda

If your bundler version is not the same as the BUNDLED WITH in the last line of your Gemfile.lock, it may occur 'could not find compatible versions for gem GEMNAME' only after adding new gem to your Gemfile.

如果您的 bundler 版本与 Gemfile.lock 最后一行中的 BUNDLED WITH 不同,则可能只有在将新 gem 添加到 Gemfile 后才会出现“找不到 gem GEMNAME 的兼容版本”。

回答by Connor Leech

go like this: gem 'activeadmin', github: 'gregbell/active_admin'in da gemfile. Active admin support for rails 4 merged into master branch Active admin install with Rails 4

像这样:gem 'activeadmin', github: 'gregbell/active_admin'在 da gemfile 中。对 rails 4 的主动管理支持合并到 master 分支使用 Rails 4 进行主动管理安装