Ruby on Rails:调试rake任务 [英] Ruby on Rails: debugging rake tasks

查看:437
本文介绍了Ruby on Rails:调试rake任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我写调试器它不会启动:

NoMethodError: undefined method `run_init_script' for Debugger:Module
from /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby-debug-base.rb:239:in `debugger'
from (irb):4

如果我运行 rake my:task --debugger ,它立即返回到控制台。如何调试耙子任务?

If I run rake my:task --debugger,it returns me to console immediately. How is it possible to debug rake tasks?

推荐答案

Andrey Kouznetsov的答案对我使用Ruby 1.9.3没有用。 ruby-debug gem似乎不支持Ruby 1.9。我不得不使用调试器宝石: https://github.com/cldwalker/debugger

Andrey Kouznetsov's answer didn't work for me using Ruby 1.9.3. The ruby-debug gem doesn't seem to support Ruby 1.9. I had to use the debugger gem: https://github.com/cldwalker/debugger.


  1. gem'debugger'添加到我的Gemfile的开发组。

  2. 运行

  3. require'debugger'添加到我的耙子顶部

  4. 添加调用 debugger 我想要在我的耙子任务中使用断点。

  5. 从命令行正常运行耙子任务,例如: rake my:task

  1. Add gem 'debugger' to my Gemfile's development group.
  2. Run bundle.
  3. Add require 'debugger' to the top of my rake task.
  4. Add a call to debugger where I wanted a breakpoint in my rake task.
  5. Run the rake task normally from the command line, e.g.: rake my:task.

这篇关于Ruby on Rails:调试rake任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆