【问题标题】:Deactivate a Gem - "you have already activated rake 0.9.3.beta.1, but my Gemfile requires rake 0.9.2"停用 Gem -“您已经激活了 rake 0.9.3.beta.1,但我的 Gemfile 需要 rake 0.9.2”
【发布时间】:2011-10-27 00:10:28
【问题描述】:

我正在尝试运行迁移,但我不断收到以下错误消息:

rake aborted! Undefined method prerequisite for nil:NilClass.

似乎我以某种方式激活了一个名为rake 0.9.3.beta.1 的gem - 但是我已经更改了gem bundle install 并运行bundle show rake,它显示rake 0.9.2 已安装。我是第一次使用 Git,所以我认为这可能与仍在使用 rake 测试版的应用程序有关 - 但我已经进行了推送,它显示 gemfile 已更新。

当我查看 gem 库时,我只能看到 rake 0.9.2 版本。我应该去哪里看?

我还有一个 Rails:Railtie deprecated 警告 - 但我认为这与我的迁移问题没有任何关系。它告诉我在 config/application.rb 中使用 config.app_generators 而不是 Railtie - 但我在文件中看不到。

这是 Config/application.rb 文件

require File.expand_path('../boot', __FILE__)

# Pick the frameworks you want:
 require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
 require "sprockets/railtie"
Bundler.require *Rails.groups(:assets) if defined?(Bundler)

module CrowdshareApp
  class Application < Rails::Application
  config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
  end
end

我的 Gemfile 看起来像这样:

source 'http://rubygems.org'

gem 'rails', '3.1.0.rc5'
gem 'sqlite3' 
group :assets do
  gem 'sass-rails', "~> 3.1.0.rc"
  gem 'coffee-rails', "~> 3.1.0.rc"
  gem 'uglifier'
end

gem 'jquery-rails'
group :development do
  gem   'rspec-rails', '2.0.0.beta.18'
end

group :test do
  gem 'rspec', '2.0.0.beta.18'
end

并且 Gemfile.lock 文件具有以下内容:

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.1.0.rc5)
      actionpack (= 3.1.0.rc5)
      mail (~> 2.3.0)
    actionpack (3.1.0.rc5)
      activemodel (= 3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      i18n (~> 0.6)
      rack (~> 1.3.1)
      rack-cache (~> 1.0.2)
      rack-mount (~> 0.8.1)
      rack-test (~> 0.6.0)
      sprockets (~> 2.0.0.beta.12)
    activemodel (3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
      bcrypt-ruby (~> 2.1.4)
      builder (~> 3.0.0)
      i18n (~> 0.6)
    activerecord (3.1.0.rc5)
      activemodel (= 3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
      arel (~> 2.1.4)
      tzinfo (~> 0.3.29)
    activeresource (3.1.0.rc5)
      activemodel (= 3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
    activesupport (3.1.0.rc5)
      multi_json (~> 1.0)
    arel (2.1.4)
    bcrypt-ruby (2.1.4-x86-mingw32)
    builder (3.0.0)
    coffee-rails (3.1.0.rc.5)
      actionpack (~> 3.1.0.rc1)
      coffee-script (>= 2.2.0)
      railties (~> 3.1.0.rc1)
      sprockets (>= 2.0.0.beta.9)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.1.2)
    diff-lcs (1.1.2)
    erubis (2.7.0)
    execjs (1.2.4)
      multi_json (~> 1.0)
    hike (1.2.0)
    i18n (0.6.0)
    jquery-rails (1.0.13)
      railties (~> 3.0)
      thor (~> 0.14)
    mail (2.3.0)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    multi_json (1.0.3)
    nokogiri (1.5.0-x86-mingw32)
    polyglot (0.3.2)
    rack (1.3.2)
    rack-cache (1.0.2)
      rack (>= 0.4)
    rack-mount (0.8.2)
      rack (>= 1.0.0)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.1.0.rc5)
      actionmailer (= 3.1.0.rc5)
      actionpack (= 3.1.0.rc5)
      activerecord (= 3.1.0.rc5)
      activeresource (= 3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
      bundler (~> 1.0)
      railties (= 3.1.0.rc5)
    railties (3.1.0.rc5)
      actionpack (= 3.1.0.rc5)
      activesupport (= 3.1.0.rc5)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2)
    rdoc (3.9.2)
    rspec (2.0.0.beta.18)
      rspec-core (= 2.0.0.beta.18)
      rspec-expectations (= 2.0.0.beta.18)
      rspec-mocks (= 2.0.0.beta.18)
    rspec-core (2.0.0.beta.18)
    rspec-expectations (2.0.0.beta.18)
      diff-lcs (>= 1.1.2)
    rspec-mocks (2.0.0.beta.18)
    rspec-rails (2.0.0.beta.18)
      rspec (>= 2.0.0.beta.14)
      webrat (>= 0.7.0)
    sass (3.1.7)
    sass-rails (3.1.0.rc.5)
      actionpack (~> 3.1.0.rc1)
      railties (~> 3.1.0.rc1)
      sass (>= 3.1.4)
      sprockets (>= 2.0.0.beta.9)
    sprockets (2.0.0.beta.13)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (!= 1.3.0, ~> 1.1)
    sqlite3 (1.3.4-x86-mingw32)
    thor (0.14.6)
    tilt (1.3.2)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    uglifier (1.0.0)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)
    webrat (0.7.3)
      nokogiri (>= 1.2.0)
      rack (>= 1.0)
      rack-test (>= 0.5.3)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  coffee-rails (~> 3.1.0.rc)
  jquery-rails
  rails (= 3.1.0.rc5)
  rspec (= 2.0.0.beta.18)
  rspec-rails (= 2.0.0.beta.18)
  sass-rails (~> 3.1.0.rc)
  sqlite3
  uglifier

【问题讨论】:

    标签: ruby-on-rails ruby gem rake


    【解决方案1】:

    尝试删除您的 Gemfile.lock 文件并再次运行 bundle install

    【讨论】:

    • 酷,删除 Gemfile.lock 为我工作!谢谢!
    • 删除 Gemfile.lock 可能真的搞砸了。它存在是有原因的。本质上,您正在运行捆绑更新,这会将您的所有 gem 更新到最新的兼容版本。
    • 我从Gemfile 中删除了spring,运行bundle,添加回来,运行bundle。这为我解决了问题。
    【解决方案2】:

    对我有用的另一种方法是转到 Gemfile.lock 并将 Rake 版本从 0.9.2.2 更改为 0.9.3.beta.1。

    【讨论】:

    • 巧妙!我用这个技巧用 Ruby 2 + Rails 4 制作 ri wirk。这不是因为 Railties 4 需要 Rdoc ~>3.4,而是 Ruby 2 需要 Rdoc 4。缺点是下一代 Gemfile.lock 将使我的项目失败,如果我忘记再次编辑它,而且我肯定会忘记它。
    【解决方案3】:

    我遇到了同样的问题,并在以下链接的帮助下解决了。 他们可以帮助理解有关此特定问题的一些概念以及如何以及为什么使用bundle exec rake db:migrate

    您还可以选择使用gem uninstall rake,然后选择要删除的版本。

    Read Before installing rails 3.1

    Rake 0.9 and gem version constraints by David Chelimsky

    【讨论】:

      猜你喜欢
      • 2011-11-26
      • 2014-06-10
      • 2011-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 2011-09-07
      相关资源
      最近更新 更多