So I tried to run ruby-debug in a script someone else had written. Yet when it hit the debugger command, I got this error:
INTERNAL ERROR!!! Insecure operation `chdir' at level 2
/usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.8.1/lib/ruby-debug-base.rb:94:in `chdir'
/usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.8.1/lib/ruby-debug-base.rb:94:in `source_for'
/usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.8.1/lib/ruby-debug-base.rb:106:in `line_at'
/usr/local/lib/ruby/gems/1.8/gems/ruby-debug-0.8.1/cli/ruby-debug/processor.rb:65:in `__at_line'
(eval):5:in `at_line'
/usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
(eval):3:in `at_line'
It turns out that the error was caused because the $SAFE level of the script had been set to 2:
$SAFE=2
According to Programming Ruby, when $SAFE >= 2, the script can't:
* load program files from globally writable locations.
* change, make, or remove directories, or use chroot.
* load a file from a tainted filename starting with ~.
* use [a bunch of functions--see link above for details]
* handle signals using trap.
Ruby-debug apparently tries to change directories ('chdir'), which caused the error. By commenting out the $SAFE level, I was able to run debugger.