For a long time I have been unable to use a debugger in an IDE for Ruby. I couldn’t ever get the correct gems installed into Netbeans and had just given up. Today, as a part of setting up my computer after a motherboard transplant, I have found a solution. This might be useful for others so I will post it here.
What I have now is Aptana Studio 3 with Ruby 1.9.3p551; with a working debugger!
I downloaded the following files:
The steps to install (on Windows 7) are:
- Run the ruby installer and tick all options.
- Run the DevKit application, this will unzip its contents. Choose a permanent target folder for the extracted files.
- Open a DOS window and change the folder to wherever the DevKit files were extracted.
- In the DevKit folder run ‘ruby dk.rb init’ and then ‘ruby dk.rb install’
- Then in the same folder (although it doesn’t matter) run ‘gem install debugger’ and then ‘gem install debugger’
- Exit the DOS window
- Run the Aptana installer allowing this to install all options.
- Check the debugger by doing the following.
- Create a Ruby project in Aptana
- Once the project is created Add a new file, this must have an explicit ‘.rb’ otherwise the IDE won’t treat it as a ruby source file (you’d think a new file added to a ruby project would be ruby by default).
- Add the following code and set a breakpoint on the puts. In the Run menu invoke Debug. The program should stop at the puts (without doing any output). Then press F6 repeatedly to execute the program within the debugger, the breakpoint will get hit once more and then the program will exit.
a = ["aaa", "bbb"] a.each do |s| puts s end
Hope this works for you. Let me know if not.