19

Using RubyMine 3.0, I set up a Rake configuration to run a Unit Test. Then I set some breakpoints, then ran the Rake task. No breakpoints were hit, the test just executed like normal and then exited.

Does the RubyMine debugger not work through Rake?

ep4169
  • 2,345
  • 2
  • 17
  • 20

3 Answers3

22

Try this:

  1. Go to Run -> Edit Configurations
  2. Expand the Rake node and add new rake configuration for your rake task (if not already done)
  3. Go to Run -> Debug...
  4. Select your configured rake task.
Derek Prior
  • 3,497
  • 1
  • 25
  • 30
  • Has anybody been successful with this on RM 3.1.1 (MacOSX edition)? I haven't had any luck so far :( – Jan Hettich Jun 17 '11 at 06:51
  • I'm hitting this problem as well. I notice that: the command runs like: "rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets", so maybe setting the env to production is what is disturbing the breakpoints. – justingordon Dec 31 '11 at 23:13
  • After configuring the rake task, start the debugger, and then start the rake task (Tools-> Run Rake Task -> select your rake task). This worked for me on mac. – Gyanendra Singh Sep 10 '12 at 07:01
  • @user523146 What does 'start the debugger' mean in this case? Changing the configuration works for me, but when I hit a breakpoint, I get 'rake aborted! undefined method `always_run' for Debugger::LoadCommand:Class' – Sandro L Oct 08 '13 at 09:30
  • You need to specify the namespace as well for the rake task. My guess is you are not doing that. By starting the debugger, I meant selecting the rake task configuration from the select/run debug configuration. After this click debug. – Gyanendra Singh Oct 08 '13 at 15:51
3

The Edit/Debug Configurations tab can be a little confusing when setting up rake tasks. I will assume you followed this approach:

Run > Edit Configurations
Select Rake from the List and select the + button (Add New Configuration) 

You are greeted with a Configuration tab:

Name

The name attribute just assigns a unique name for this task. You can call it whatever you want.

Task Name

This one is important for rake tasks. This specifies the name of the rake task to be executed. So let's say you wanted to run "rake db:migrate" in debug mode, then for the task name here, you would put "db:migrate" without the quotes.

Turn on invoke/execute tracing, enable full backtrace (--trace)

This option is useful to turn on the standard rake --trace option.

Ruby Arguments

The other useful option is to specify the arguments to be passed to the Ruby interpreter.

Those are the main options. Now you can use Run > Debug and it will stop at breakpoints in the rake task itself.

Cody
  • 2,467
  • 2
  • 21
  • 30
Daniel Viglione
  • 8,014
  • 9
  • 67
  • 101
1

The above answer is correct. I just want to elaborate on it a little bit, when using a mountable engine. In that case, I had to do the following:

  1. Run > Edit Configuration > Rake

  2. Enter task name e.g. scan_spreadsheet

  3. Change the working directory to your main application or dummy application, not the engine root directory.

  4. If you are using RVM with multiple gemsets, select the second option for Ruby SDK and select the correct gemset

Donato
  • 2,727
  • 6
  • 29
  • 59