It looks like something changed in 1.0.21 around f...
# ksp
z
It looks like something changed in 1.0.21 around file module ownership. I looked at the “Calling KSP2 in Programs” docs and they don’t mention anything specific for setting up modules. When I look in the debugger, I do see a module there, but I’m not able to breakpoint it (it appears the class files don’t match published sources). Functionally, it just doesn’t seem to match the
contains
call when it checks if the virtual file is in the module’s content scope. This effectively breaks compile testing KSP plugins as well as I’m not able to figure out a workaround. PR is here: https://github.com/ZacSweers/kotlin-compile-testing/pull/196
Copy code
logging: No services were given. Not running kapt steps.
v: [ksp] round 1 of processing
Cannot find a KtModule for the VirtualFile
ksp.org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Cannot find a KtModule for the VirtualFile
	at ksp.org.jetbrains.kotlin.analysis.project.structure.impl.KtStandaloneProjectStructureProvider.getModule(KtStandaloneProjectStructureProvider.kt:62)
	at ksp.org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider$Companion.getModule(ProjectStructureProvider.kt:105)
	at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSessionKt.getModule(LLFirResolveSession.kt:103)
	at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirResolvableResolveSession.getModuleComponentsForElement(LLFirResolvableResolveSession.kt:56)
	at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirResolvableResolveSession.getOrBuildFirFile$low_level_api_fir(LLFirResolvableResolveSession.kt:51)
	at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.api.LowLevelFirApiFacadeKt.getOrBuildFirFile(LowLevelFirApiFacade.kt:137)
	at ksp.org.jetbrains.kotlin.analysis.api.fir.symbols.KtFirSymbolProvider.getFileSymbol(KtFirSymbolProvider.kt:57)
	at ksp.org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProviderMixIn.getFileSymbol(KtSymbolProvider.kt:137)
	at com.google.devtools.ksp.impl.KotlinSymbolProcessing.prepareNewKSFiles(KotlinSymbolProcessing.kt:403)
	at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:552)
	at com.tschuchort.compiletesting.Ksp2PrecursorTool.execute(Ksp2.kt:116)
edit: filed https://github.com/google/ksp/issues/1908
t
May I know what the Gradle command is to reproduce?
Can you try to replace relative paths with absolute paths when setting up source roots?
Looks like this was introduced recently and not caught by our tests 😢
Correction: as a workaround, the source output directories need to be absolute.
z
On mobile now but the KspTest class is the suite to run
Source output dirs? The error seemed to be related to not being able to validate the input source file, before producing any outputs
t
Thanks, I have to leave for a while and will verify the workaround and work on a proper fix a few hours later.
👍 1
z
But maybe I’m misremembering and it’s happening in the second round of processing when reading the output file
t
Unfortunately(?) it works on my machine (Linux). I'll find a Mac and a Windows tomorrow.
z
🤔
Yeah I’m testing on Mac but CI is running Linux
I’ve checked every path to make sure they are using absolute paths and it hasn’t changed anything. You’re right though, it is running fine on linux