【发布时间】: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