Gem Rails 3.0.5 下 rake 不能工作,怎么破?

sensi · 2015年01月14日 · 最后由 sensi 回复于 2015年01月14日 · 2952 次阅读

看的书是 web 开发敏捷之道 rails 应用…第四版,使用的是 rails3.0.5。然后问题就出现了(之前用的是 4.0) rake 命令一直不能使用,出现的错误是这个样子的

rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks/documentation.rake:1:in `require'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks.rb:15:in `load'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks.rb:15:in `block in <top (required)>'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks.rb:14:in `each'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/tasks.rb:14:in `<top (required)>'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/application.rb:213:in `require'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/application.rb:213:in `initialize_tasks'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/application.rb:139:in `load_tasks'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
/Users/donghaoran/work/demo/Rakefile:6:in `<top (required)>'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
donghaorandeMacBook-Air:demo donghaoran$ rake routes

我也装逼的在 stackoverflow 上发现了一个解决之道,是修改 rakefile,哈哈 最后还是不能生效,运行结果是这样的:

LoadError: cannot load such file -- tasks/rails
/Users/donghaoran/work/depot/Rakefile:8:in `require'
/Users/donghaoran/work/depot/Rakefile:8:in `<top (required)>'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
/Users/donghaoran/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

搜索发现发现是 rails3.0.5 必须使用 rake0.8.7 才行,可是 rake 现在默认的是 0.9.6,这个问题该怎么解决?

rake 版本写到 Gemfile 然后 bundle exec rake

#1 楼 @Rei 真棒,我咋没想到呢!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号