How does Ruby do X?

The answer can usually be found with ruby -rdebug or ruby -rtracer. There is also the trick with RUBYOPT. If you are executing something with bundler then you can run RUBYOPT="-rdebug" bundle exec ${command} and you will be dropped in the debugger as usual.