Can't inject CoroutineScope into light service constructors

Hi!

I’m trying to move the execution of some stuff inside a coroutine, and for that I’d like to use a CoroutineScope injected into a light service constructor as mentioned here: Launching Coroutines | IntelliJ Platform Plugin SDK

However, when I invoke the instantiation of my service, I receive the following message:

2025-07-21 18:50:11,549 [  85435]   WARN - #c.i.s.ComponentManagerImpl - Class 'class com.my.project.MyService' does not define any of supported signatures '[(Project)void, (Project,CoroutineScope)void, (CoroutineScope)void, ()void]'
com.intellij.platform.instanceContainer.instantiation.InstantiationException: Class 'class com.my.project.MyService' does not define any of supported signatures '[(Project)void, (Project,CoroutineScope)void, (CoroutineScope)void, ()void]'
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.findConstructor(instantiate.kt:64)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.instantiate(instantiate.kt:32)

After some debugging I can see the more specific exception that is an IllegalAccessException with:

detailMessage: "no such constructor: com.my.project.MyService.<init>(Project,CoroutineScope)void/invokeSpecial"
cause: "java.lang.LinkageError: bad method type alias: (Project,CoroutineScope)void not visible from class com.my.project.MyService"

I get this error with both project- and application-level services, and only if the CoroutineScope argument is added, and with as simple of a service as this:

@Service
class MyService(private val cs: CoroutineScope)

I haven’t been able to find information or example if any specific configuration, dependency, etc. should be added to the project in order to make this injection work, so I’m stuck here.

Has anyone run in this before? I’d appreciate any insight. Thank you!

Just a thought, but I remember that I had a similar problem when my plugin bundled its own coroutines library. The IDE looks for a constructor using the IDE‘s bundled coroutines library, but the plugin only definea a constructor with the classes from its own library. Unbundling / dropping the own coroutines dependency fixed this…

Please do not bundle your own Kotlin stdlib and coroutines, usually it is a problem

Thank you for the tip.

It wasn’t bundled explicitly, but it was coming transitively from other dependencies, so exluding coroutines solved the issue.