Run debugger in tests with gradle on wsl doesn't work: agent library failed Agent_OnLoad: instrument
已回答
I have windows 11 + wsl2. IDE is on windows and project is on wsl. After upgrade intellij Idea Ultimate to 2025.2 debugger in unit test stop working with error:
Error occurred during initialization of VM
Error opening zip file or JAR manifest missing : C:\Users\username\AppData\Local\JetBrains\IntelliJIdea2025.2\captureAgent\debugger-agent.jar
agent library failed Agent_OnLoad: instrument
I checked it that before update everything worked fine, so it is linked with update to the newest version
请先登录再写评论。
Hi Piotr16pl
Thanks for the report. We have a bug registered for this problem, please follow updates in the ticket IDEA-377411.
The debugger error in IntelliJ IDEA 2025.2 is a known issue caused by a **pathing mismatch** between Windows and WSL2. The IDE, running on Windows, tries to load the `debugger-agent.jar` file using a Windows-style path (`C:\Users\...`), but the test runner's VM operates in the Linux environment of WSL2, which cannot interpret that path. The solution is to create a **symbolic link** within your WSL mymilestonecard terminal that points to the location of the `.jar` file on your Windows drive, allowing the VM to access it correctly.
Ackerman254ricksar How exactly should I create the symbolic link? Where should I put it in? How to force intellij to use that link instead windows path?
Hello Ackerman254ricksar How exactly should I create the symbolic link? Where should I put it in? How to force intellij to use that link instead windows path?
Hi Mateusz ,
According to Ackerman254ricksar suggestion, here is the answer to your questions:
ln -sin WSL, pointing from a Linux path you control to the/mnt/c/…path of debugger-agent.jar/usr/local/share/idea-debugor/opt/idea-agentare good, stable choices.-javaagent:<linux-path-to-symlink>/debugger-agent.jarto the Run/Debug Configuration VM options for the app or tests.You also can try the next three approaches:
Option A — Create a symlink inside WSL to the Windows JAR
C:\Users<you>\AppData\Local\JetBrains\IntelliJIdea2025.2\plugins\java\lib\debugger-agent.jar)./mnt/c/Users//AppData/Local/JetBrains/IntelliJIdea2025.2/plugins/java/lib/debugger-agent.jar/usr/local/share/idea-debugsudo mkdir -p /usr/local/share/idea-debugsudo ln -s "/mnt/c/Users//AppData/Local/JetBrains/IntelliJIdea2025.2/plugins/java/lib/debugger-agent.jar" /usr/local/share/idea-debug/debugger-agent.jarRun/Debug Configuration | VM options, add:
-javaagent:/usr/local/share/idea-debug/debugger-agent.jarOption B — Map the Windows directory into a WSL bind mount
Create a Linux mount point:
sudo mkdir -p /opt/idea-agentBind-mount the Windows folder that contains the agent:
sudo mount --bind "/mnt/c/Users//AppData/Local/JetBrains/IntelliJIdea2025.2/plugins/java/lib" /opt/idea-agentUse VMOption
-javaagent:/opt/idea-agent/debugger-agent.jarTo persist across sessions, add a line to /etc/fstab (optional):
/mnt/c/Users//AppData/Local/JetBrains/IntelliJIdea2025.2/plugins/java/lib /opt/idea-agent none bind 0 0Option C — Make IntelliJ launch and debug directly in WSL (no path translation needed)
Monica sorry but I doubt your answer was generated by AI.
I don't see there are any places to configure `Run/Debug Configuration | VM options` for Option A and B, unless you are talking about the VM options for one particular run. But I have also tried it, still doing the same thing.
As for option C, at least for me, the reason I am getting the same error is that I am using JDK located in WSL2.
Hi Cuichen Li94
Thanks for the update. I apologize if I wasn't so clear, I meant Run/Debug configuration.
The problem is related to the way path is read, as soon as we find a workaround we'll share it. I keep looking at it.
Meanwhile please subscribe to the original issue for further updates from development side.
I tried option A, but same issue.
The path provided by “-javaagent” related to WSL path is not used and path Windows style “C:\…” continues to be used :(
Hi Damien Guerin
Thanks for testing the solutions. Our developers are working hard to solve the issue as soon as possible. Please subscribe and upvote the original bug, IDEA-285542, and keep track of its progress.
If we find a workaround that fits for all scenarios in the meantime we'll add it in the ticket.