Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

echo back every Ruby code line like sh -x?

Is there a way to have a ruby script echo back (or log to file I can tail -f) every line executed, similar to bash -x or @echo on in DOS?

ruby -w doesn't do it--only increases verbosity of warnings etc.

Researched Unroller but it doesn't work, possibly too dated. Uncompilable dependencies.

I use irb a lot but in this case I need something non-interactive eg. to inspect post-mortem.

like image 603
Marcos Avatar asked Dec 19 '11 19:12

Marcos


2 Answers

You can use

ruby -rtracer [your_script.rb]

There is also ruby-debug which can do

rdebug --trace [your_script.rb]
like image 171
Niklas B. Avatar answered Sep 28 '22 05:09

Niklas B.


IRB does the trick:

irb script.rb
like image 43
chrish. Avatar answered Sep 28 '22 04:09

chrish.