3

I added debugger and require 'ruby-debug' in my task to debug it.

When I run my task from the console, it does hit the debugger, but doesn't let me inspect any variables. For example, if there's a line in my task :

my_var = 1 + 2

and I type my_var or my_var.inspect, while debugging, it says :

*** Unknown command: "my_var".  Try "help".

What am I missing ?

Erez Rabih
  • 15,562
  • 3
  • 47
  • 64
Myxtic
  • 5,679
  • 5
  • 48
  • 69

3 Answers3

5

Try to run

e my_var

If autoeval isn't set by default, you have to prefix any evaluation expression with e.

By the way, to set autoeval put the following line in ~/.rdebugrc:

set autoeval

After you do that, any command which is not recognized by the debugger will be considered as an attempt to evaluate en expression so you could just type the variable name to get its value.

Erez Rabih
  • 15,562
  • 3
  • 47
  • 64
2

just run

p my_var 

For more options, type help

Ravi Sankar Raju
  • 2,850
  • 3
  • 18
  • 16
2

if you want to get the value of a variable try using
=> display < variable-name >
this line will display the variable at each and every step.... and if you want to undisplay it, then use this command.
=> undisplay < number shown before variable-name in output >

Also try typing 'help', this will list all the commands that you can use while debugging. Try them.
We can use 'p', 'pp', 'eval', 'list' etc.

Akshay Vishnoi
  • 1,252
  • 12
  • 15