kotlin-debug-adapter icon indicating copy to clipboard operation
kotlin-debug-adapter copied to clipboard

Incorrect classPath is used to launch debuggee

Open NecroKote opened this issue 1 year ago • 2 comments

Possibly relates to #69

I stumbled upon similar issue while I was trying to launch a Ktor application.

After some debugging, I traced the root cause to the fact that DebugAdapter re-uses classPath discovery mechanism of kotlin-language-server and by default it only takes into account compileClasspath while it should use runtimeClasspath

For me, the issue was fixed after I've build my own debugAdapter with modified KLS with it.compileClasspath.forEach replaced with it.runtimeClasspath.forEach.

@fwcd can you please shed some light on the reason why debug adapter launches a "debuggee" with it's compile time dependencies and not runtimeDependencies ? I might be able to contribute if I understand the context better.

Sorry for the ping, and thanks for the great work you did!

NecroKote avatar Aug 13 '24 11:08 NecroKote

You are right, it should probably use the runtime classpath instead. I suggest adding a parameter (e.g. a flag that defines whether to use the compile/runtime classpath) to the upstream Gradle class path resolver in KLS, so we can still share most of the logic, haven't looked into what the best way of passing arguments to Gradle scripts is though. Feel free to open a PR.

fwcd avatar Aug 13 '24 11:08 fwcd

@fwcd hopefully I get it all right :)

NecroKote avatar Aug 13 '24 16:08 NecroKote