How to Debug Your Own IntelliJ IDEA Instance
Some time ago, I have adopted CodeNarc IDEA plugin which helps to detect(and soon it will help fixing) Groovy code style violations.
CodeNarc - IntelliJ IDEs Plugin | Marketplace
CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more.
I have a version of a plugin in the beta channel which works great but sometimes the plugin code throws a
StackOverflowError that I am not able to emulate in the sandbox but that only occurs on my own IntelliJ IDEA instance. It has been also reported by my coworkers who help me with testing so I wanted to fix the issue before releasing the plugin to the general public. I need to be able to debug my own IntelliJ IDEA instance to get more details about the issue.
The first step is to launch the instance in debug mode. To do so, you need to edit the
idea.vmoptions file using Edit Custom VM Options… action:
Add the following option to the end of the file:
Save the file and restart Intellij IDEA.
If you fail to update the file for some reason and your IntelliJ instance won't start anymore then you can find the location of
idea.vmoptions in the IntelliJ configuration directory and edit it with another text editor.
You cannot debug the instance from within the instance itself. One of the options is to launch the sandboxed IDE from the plugin's project. If you are using Gradle to develop the plugin then you can run the following task:
Other options are either downloading a different edition of the IDE (e.g. the community edition instead of ultimate) or launching the IDE with different configuration directories.
Changing IDE default directories used for config, plugins, and caches storage
user profile drive runs out of space disk is slow and you want to use faster HDD or SSD for caches default user profile…
Once your regular IntelliJ IDEA instance has started then launch the other one, open the plugin's code and run Attach to Process action:
You will see
idea process ready to be attached:
You will see that the debugger is attached to your IDE now and you can start debugging your plugin.
Once you are finished, do not forget to remove the debugging configuration from the
Many thanks to Yann Cébron, the developer advocate of IntelliJ Platform, for helping me setting up the process.