Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging in ruby 1.9

What do you guys use for debugging in ruby 1.9? rdebug doesn't seem to be compatible.. is there anything out there?

like image 252
cloudhead Avatar asked Jul 05 '09 04:07

cloudhead


People also ask

How do I debug a Ruby file?

To help deal with bugs, the standard distribution of Ruby includes a debugger. In order to start the Ruby debugger, load the debug library using the command-line option -r debug. The debugger stops before the first line of executable code and asks for the input of user commands.

How do I debug a code in Visual Studio Ruby?

Go to the debugger view of VS Code and hit the gear icon. Choose Ruby or Ruby Debugger from the prompt window, then you'll get the sample launch config in . vscode/launch.

What is Ruby-debug IDE?

The 'ruby-debug-ide' gem provides the protocol to establish communication between the debugger engine (such as debase or ruby-debug-base) and IDEs (for example, RubyMine, Visual Studio Code, or Eclipse).

What is Byebug in Ruby?

Byebug is a Ruby debugger. It's implemented using the TracePoint C API for execution control and the Debug Inspector C API for call stack navigation. The core component provides support that front-ends can build on.


2 Answers

ruby-debug19 is not maintained anymore. All the other answers are outdated.

But there's an alternative:

debugger to the rescue!

Put this in your Gemfile:

gem 'debugger', group: [:development, :test] 

It just works. - And it is included in the rails Gemfile since 3.2.something to replace ruby-debug19. It has the exact same functionality and is actively maintained.

like image 57
iblue Avatar answered Oct 28 '22 04:10

iblue


UPDATE FOR RUBY 2.0+ and FOLLOWING

byebug is the currently recommended debugger for Ruby 2.0+

This issue has been documented here, and cldwalker, the author of debugger, notes that debugger will be scoped to Ruby 1.9.2 and 1.9.3.

UPDATE 2

It is true that ruby-debug is not actively maintained even if I can't find anywhere that is not maintained any longer.

You can use the new debugger gem if you need a help to start with the new gem you can see Ryan Bates rails cast.

In your Gemfile put:

gem 'debugger', group: [:development, :test] 

You can then add a breakpoint anywhere in your code using the debugger keyword.

YOU CAN STILL USE

linecache19 and ruby-debug-base19 with:

bash < <(curl -L https://raw.github.com/gist/1333785)

OLD ANSWERS

Just an add on about this with rvm, ruby 1.9.1-p378. True story is that even if ruby-debug is 1.9.x ready, linecache-0.43 is not. The solution is to install:

gem install ruby-debug19 

This solves the problem for me.

OLD UPDATE

If you are having problems with ruby 1.9.2 and Rails 3 debugging putting:

gem 'ruby-debug-base19', "0.11.24" gem 'ruby-debug19', "0.11.6" 

In your Gemfile and doing a

bundle install 

Will make you a happy debugger again.

like image 32
tommasop Avatar answered Oct 28 '22 05:10

tommasop