简体   繁体   English

Rake 和 Ruby 在 Rails 上的问题

[英]Problems with Rake and Ruby on Rails

I have been trying to run rake but it seems that ever since I updated ruby gems rake is failing.我一直在尝试运行 rake,但似乎自从我更新 ruby gems rake 以来就失败了。

This morning I ran:今天早上我跑了:

gem update --system

And ever since, rake has been failing with the following error:从那以后,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)

I have been reading about this problem and it seems that there is a problem with rake 0.9.x that breaks rails but when I check my rake version, I am running 0.8.7:我一直在阅读有关此问题的信息,似乎 rake 0.9.x 存在问题,它破坏了轨道,但是当我检查我的 rake 版本时,我正在运行 0.8.7:

$ rake --version                                                                                    
rake, version 0.8.7

I have tried uninstalling rake and reinstalling it, using bundler, etc and at this point I am pretty stuck.我已经尝试卸载 rake 并重新安装它,使用捆绑器等,此时我非常卡住。 Thanks in advance.提前致谢。

Edit:编辑:

My Rakefile (located in my app root directory)我的 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

I would suggest using the bundled binary version of rake to avoid this issue.我建议使用 rake 的捆绑二进制版本来避免这个问题。

bundle exec rake db:migrate

If you installed your bundle using binstubs ( bundle install --binstubs ) then you can also use the bin version of rake which is equivalent to the bundle exec rake command:如果您使用 binstubs ( bundle install --binstubs ) 安装了您的包,那么您还可以使用 rake 的 bin 版本,它等效于bundle exec rake命令:

bin/rake db:migrate

PS: I would also recommend using RVM instead of installing Ruby using sudo for all users. PS:我还建议所有用户使用RVM而不是使用 sudo 安装 Ruby。 This allows you to keep more modular ruby and gem installation.这允许您保留更多模块化 ruby 和 gem 安装。

You should remove rake 0.9.x (you may have 0.9.2 installed) by doing您应该通过执行删除 rake 0.9.x(您可能安装了 0.9.2)

gem uninstall rake -v=0.9.2

And then run bundle update然后运行捆绑更新

bundle update

Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM