1

我一直在尝试运行 rake,但似乎自从我更新了 ruby​​ gems rake 就失败了。

今天早上我跑了:

gem update --system

从那以后,rake 一直失败并出现以下错误:

$ rake db:migrate                                                                                 
rake aborted!
undefined method `specifications' for "/usr/lib/ruby/gems/1.9.1":String
/home/cknadler/projects/ecommerce/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)

我一直在阅读有关此问题的信息,似乎 rake 0.9.x 存在问题,它破坏了轨道,但是当我检查我的 rake 版本时,我正在运行 0.8.7:

$ rake --version                                                                                    
rake, version 0.8.7

我已经尝试卸载 rake 并重新安装它,使用捆绑器等,此时我非常卡住。提前致谢。

编辑:

我的 Rakefile(位于我的应用程序根目录中)

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

Ecommerce::Application.load_tasks
4

2 回答 2

4

我建议使用 rake 的捆绑二进制版本来避免这个问题。

bundle exec rake db:migrate

如果您使用 binstubs ( bundle install --binstubs) 安装了您的包,那么您还可以使用 rake 的 bin 版本,它等效于以下bundle exec rake命令:

bin/rake db:migrate

PS:我还建议所有用户使用RVM而不是使用 sudo 安装 Ruby。这允许您保留更多模块化的 ruby​​ 和 gem 安装。

于 2011-06-09T20:25:43.140 回答
1

您应该通过执行删除 rake 0.9.x(您可能安装了 0.9.2)

gem uninstall rake -v=0.9.2

然后运行捆绑更新

bundle update

希望有帮助。

于 2011-06-10T02:15:09.590 回答