Today we’re glad to bring out the RubyMine 2016.3 RC (build 163.7743.40).
Attach to local process
Starting with v2016.3, RubyMine allows you to attach to locally running Ruby/Rails processes with the IDE’s debugger. The new feature makes it possible to debug an ongoing Ruby/Rails process, whether you are running it from the IDE, terminal, or a custom pipeline.
Imagine having a working Ruby/Rails project with a custom setup. Everything works properly, but there’s some annoying routine affecting your app’s performance. You’d probably want to investigate and fix the issue in that process without having to spend time configuring the debugging environment for the whole project.
You could use Rails autoloader and the newly inserted ‘binding.pry’ to start debugging session in console. However, Attach To Process will go far beyond that, allowing you to exploit the whole feature set of the RubyMine debugger without any configuration.
Just as a trivial example, let’s attach to a Ruby script counting from 1 through 20 with a 3-second delay after every displayed number. The script is run from the terminal:
To attach to this process, in RubyMine, choose Run | Attach to Local Process. The IDE will show all ongoing local Ruby processes. Check the process you want to attach to, and RubyMine will connect the debugger to the specified process:
Note that you don’t need to manually install any debugging gems to attach to process. The IDE will find your Ruby version, the gemset that was defined to run the script, and will install all missing gems automatically.
Once the load is complete, you’ll come across a familiar debugger UI allowing you to use its whole set of features, namely breakpoints, stepping in, variable views, etc. (if you need a refresher on the RubyMine debugger and its functionality, please check the related Help section):
You will also be notified on the debugger connection right where you local process is running, e.g. in the terminal:
We’d like to note that we’ll continue working on Attach to Process, in order to provide you with the ability to attach to Ruby/Rails processes located on remote servers, together with other improvements.
Should you have any Ruby/Rails-specific use cases that require or are missing convenient debugging for local processes, please share them in the comments below.
Your RubyMine Team