捆绑安装失败:Bundler无法找到gem“railties”的兼容版本:

时间:2013-08-13 14:39:30

标签: ruby-on-rails bundler ruby-on-rails-4

我目前无法运行bundle install。它总是失败:

$ bundle install
Fetching source index from https://rubygems.org/
Updating git://github.com/gregbell/active_admin.git
fatal: Could not parse object 'a9949c1524205928b18597f840e83478ba97c2ef'.
Git error: command `git reset --hard a9949c1524205928b18597f840e83478ba97c2ef` in directory /Users/noxoc/.rvm/gems/ruby-1.9.3-p385@tp-usevalue/bundler/gems/active_admin-a9949c152420 has failed.
If this error persists you could try removing the cache directory '/Users/noxoc/.rvm/gems/ruby-1.9.3-p385@tp-usevalue/cache/bundler/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca'

我已经尝试按照建议删除缓存目录。这是我的Gemfile(已排序,评论已剥离):

source 'https://rubygems.org'

gem 'active_link_to'
gem 'activeadmin'
gem 'coffee-rails'
gem 'compass-rails'
gem 'debugger', group: [:development, :test]
gem 'devise',              github: 'plataformatec/devise'
gem 'formtastic',          github: 'justinfrench/formtastic'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'jbuilder', '~> 1.2'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'rails'
gem 'rails-i18n', '~> 4.0.0.pre' # For 4.0.x
gem 'ransack'
gem 'responders',          github: 'plataformatec/responders'
gem 'sass-rails'
gem 'simple_form'
gem 'sqlite3'
gem 'turbolinks'
gem 'uglifier', '>= 1.3.0'

group :doc do
  gem 'sdoc', require: false
end

group :development, :test do
  gem "rb-fsevent", "~> 0.9.1"
  gem "guard", "1.6.2"
  gem "guard-spork"
  gem "guard-rspec", "2.5.1"
  gem "rspec-rails", "2.13.1"
  gem "shoulda-matchers", "2.1.0"
  gem "capybara", "2.1.0"
  gem "launchy", "2.2.0"
  gem 'spork-rails', :github => 'sporkrb/spork-rails'
  gem "thin"
end

让我感到困惑的是,几天前它运作得很好。

更新

正如zrl3dx建议的那样,我删除了Gemfile.lock并再次运行bundle - 这会导致此错误:

$ bundle
Updating git://github.com/gregbell/active_admin.git
Updating git://github.com/milgner/compass-rails.git
Updating git://github.com/plataformatec/devise.git
Updating git://github.com/justinfrench/formtastic.git
Updating git://github.com/josevalim/inherited_resources.git
Updating git://github.com/ernie/ransack.git
Updating git://github.com/plataformatec/responders.git
Updating git://github.com/sporkrb/spork-rails.git
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "ransack":
  In Gemfile:
    activeadmin (>= 0) ruby depends on
      ransack (>= 1.0.0) ruby

    ransack (0.7.3)

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

    coffee-rails (~> 4.0.0) ruby depends on
      railties (4.0.0.rc2)

3 个答案:

答案 0 :(得分:3)

尝试删除Gemfile.lock并再次执行bundle

尝试添加到Gemfile:

gem 'coffee-rails', git: 'git://github.com/rails/coffee-rails.git'

而不是:

gem 'coffe-rails'

编辑:

好的,我已在本地复制并尝试解决,我的更改:

gem 'coffee-rails', git: 'git://github.com/rails/coffee-rails.git'
gem 'activeadmin',         github: 'gregbell/active_admin', branch: 'rails4'
gem 'rails', git: 'https://github.com/rails/rails.git', branch: '4-0-stable'
gem 'devise'
gem 'ransack'
gem 'sass-rails', git: 'https://github.com/rails/sass-rails.git'

现在它检查出来,至少在这里。

答案 1 :(得分:2)

接受的答案中引用的Active Admin的rails4分支不再存在。它已合并为master但尚未在rubygems上发布。这个gemfile条目将使用rails4支持引用最新的提交。

gem 'activeadmin', github: 'gregbell/active_admin', :ref=> 'fe7d6a6e1bafc9e9dd765dfb3a09245ccd0b3cfd'

答案 2 :(得分:0)

如果发现这对我有用:

unset GIT_DIR

https://github.com/mislav/git-deploy/issues/27

找到