【问题标题】:Could not find rake-0.9.2.2 in any of the sources在任何来源中都找不到 rake-0.9.2.2
【发布时间】:2012-07-22 13:31:28
【问题描述】:

这是一个奇怪的问题。我在运行 rake 进行测试时遇到此错误,但在迁移时却没有。我正在运行 RVM,下面的 shell 转储应该会提供您需要的任何信息。

任何帮助将不胜感激。我见过其他几个人遇到这个问题,但还没有对我(或他们)有用的解决方案。

谢谢。

$ rake
Could not find rake-0.9.2.2 in any of the sources
Run `bundle install` to install missing gems.
Could not find rake-0.9.2.2 in any of the sources
Run `bundle install` to install missing gems.
Errors running test:units, test:functionals, test:integration!



$ ruby -v
    ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
    $ rails -v
    Rails 3.1.6

$ more .rvmrc 
rvm ruby-1.9.3-p194@...
$ rake db:rollback
==  AddAllLocationsToAlert: reverting =========================================
-- remove_column(...
   -> 0.0320s
==  AddAllLocationsToAlert: reverted (0.0321s) ================================

------- 编辑::::

我已经升级到最新的 Rails - 3.2.6。即使我使用'bundle exec',错误仍然存​​在。 (这对 3.2.6 来说并不新鲜——我仍然在 3.1 下遇到这个问题)虽然 undefined 方法是新的。

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
$ bundle exec rake
Could not find rake-0.9.2.2 in any of the sources
Run `bundle install` to install missing gems.
Could not find rake-0.9.2.2 in any of the sources
Run `bundle install` to install missing gems.
Errors running test:units! #<NoMethodError: undefined method `[]' for nil:NilClass>
Errors running test:functionals! #<RuntimeError: Command failed with status (7): [/Users/ben/.rvm/rubies/ruby-1.9.3-p194/bin...]>
Errors running test:integration! #<RuntimeError: Command failed with status (7): [/Users/ben/.rvm/rubies/ruby-1.9.3-p194/bin...]>

我的 Gemfile,按要求:

source 'http://rubygems.org'

gem 'rails', '3.2.6'

group :assets do
  gem 'sass-rails', "  ~> 3.2.5"
  gem 'coffee-rails', "~> 3.2.1"
  gem 'uglifier', '>= 1.2.6'
end

gem 'jquery-rails'

gem 'rake'
gem "mysql2"

gem "squeel"
gem 'tinymce-rails'
gem 'dynamic_form'

gem 'will_paginate'
gem 'devise'
gem 'whitelist'
gem 'rmagick'
gem 'json'
gem 'paperclip'
gem 'acts_as_list', :git => 'https://github.com/swanandp/acts_as_list'
gem 'htmlentities'
gem 'formtastic'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem 'webrat'
# end

【问题讨论】:

  • 'gem install rake' 不起作用?
  • 可能你的 Gemfile 的 test 组中的一个 gem 取决于 rake 的不同版本而不是你系统中安装的那个。
  • 本德:不。 :( Michal:现在这暗示了可能发生的事情。我在 Gemfile 中没有测试组 - 这是基于一个旧项目。它是从 rails 1 到 3.0、3.1 和现在的3.2,所以我没有使用完整的功能集。但是,那里有一些旧的宝石。一个可能会导致一些 Rake 问题。奇怪的是它只是测试我到目前为止得到它。为什么迁移工作?
  • 不,当我暂时删除所有宝石但默认的轨道宝石时,同样的错误。不过还是谢谢。
  • 对于任何关心的人,我发现将 Rails 3.2 站点部署到需要 Rails 3.0 的服务器时出现错误。它正在运行Passenger,错误导致站点失败。事实证明,Passenger 需要运行与网站运行相同版本的 Ruby。它是为较旧的 Ruby 版本编译的。在编译了一个新的Passenger 之后,我发现重新编译成功了。我可能会引用在旧 Ruby 版本下编译的旧 Gem...

标签: ruby-on-rails ruby ruby-on-rails-3.1 rake bundler


【解决方案1】:

gem 'rake', ">=0.9.2" # 在您的 Gemfile 中

然后

$ 捆绑安装

然后

$ bundle exec rake

如果上述方法无效:

$ rvm all do gem install rake -v 0.9.2.2#install rake to all ruby​​ 版本

然后再次运行 rake

【讨论】:

  • 这是一个有用的小 rmv 命令,@Ahmed。谢谢你。
【解决方案2】:

如果您使用的是 bundler(并且使用 rails,您可能会这样做),请始终像这样运行 rake:

bundle exec rake

这将获取您的 Gemfile 中指定的宝石。

【讨论】:

  • 这是其他类似线程中提供的潜在解决方案之一。不幸的是......没有。L:(
  • 更新了初始帖子以反映此建议失败。 (所以读者们,没有刺眼的 cmets)
  • 顺便说一句,我一直对这个功能感到困惑。真的很烦人!过去我通过卸载我不想要的 gem 版本来解决这个问题,但目前我只有一个版本 - 它要求的那个!我只能假设代码中的某个地方没有满足依赖关系,并且错误消息令人困惑地返回当前的 gem 版本而不是所需的版本......但我不知道如何在这里更深入地挖掘。
  • 请同时发布您的 Gemfile - 您究竟需要在其中添加rake
  • 这只是一个猜测,但请尝试将gem 'rake' 更改为gem 'rake', '~&gt; 0.9.2'gem 'rake', '~&gt; 0.9.2.2' 并重试:bundle install, bundle exec rake
猜你喜欢
  • 2012-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-31
  • 2013-12-25
  • 2017-07-18
  • 2011-11-28
相关资源
最近更新 更多