RubyMine debugger with Rake?

2019-04-18 17:26发布

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?

3条回答
聊天终结者
2楼-- · 2019-04-18 17:38

The Edit/Debug Configurations tab can be a littRuby Argumentsle 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 Ruby Argumentsfor 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.

查看更多
何必那么认真
3楼-- · 2019-04-18 17:50

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

查看更多
叼着烟拽天下
4楼-- · 2019-04-18 17:54

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.
查看更多
登录 后发表回答