In trying to update to alpha08, I'm seeing a crash...
# ksp
z
In trying to update to alpha08, I'm seeing a crash in KSP and not sure if it's an issue in my tests or something I should file. Let me know if this seems familiar - https://github.com/ZacSweers/MoshiX/pull/107
👀 1
Copy code
e: [ksp] org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException: Descriptor wasn't found for declaration CLASS
	at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)
	at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:17)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.findClassDescriptor(LazyDeclarationResolver.kt:88)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getClassDescriptor(LazyDeclarationResolver.kt:62)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getMemberScopeDeclaredIn$frontend(LazyDeclarationResolver.kt:227)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitProperty(LazyDeclarationResolver.kt:181)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitProperty(LazyDeclarationResolver.kt:94)
	at org.jetbrains.kotlin.psi.KtProperty.accept(KtProperty.java:58)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:94)
	at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:91)
	at org.jetbrains.kotlin.resolve.lazy.ResolveSession.resolveToDescriptor(ResolveSession.java:361)
	at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveDeclaration(ResolverImpl.kt:352)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:41)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:34)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.getPropertyDescriptor(KSPropertyDeclarationImpl.kt)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.access$getPropertyDescriptor$p(KSPropertyDeclarationImpl.kt:34)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$getter$2.invoke(KSPropertyDeclarationImpl.kt:63)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$getter$2.invoke(KSPropertyDeclarationImpl.kt:34)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.getGetter(KSPropertyDeclarationImpl.kt)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitPropertyDeclaration(ResolverImpl.kt:263)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitPropertyDeclaration(ResolverImpl.kt:223)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.accept(KSPropertyDeclarationImpl.kt:100)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitClassDeclaration(ResolverImpl.kt:239)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitClassDeclaration(ResolverImpl.kt:223)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSClassDeclarationImpl.accept(KSClassDeclarationImpl.kt:121)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitFile(ResolverImpl.kt:233)
	at com.google.devtools.ksp.processing.impl.ResolverImpl$getSymbolsWithAnnotation$visitor$1.visitFile(ResolverImpl.kt:223)
	at com.google.devtools.ksp.symbol.impl.kotlin.KSFileImpl.accept(KSFileImpl.kt:59)
	at com.google.devtools.ksp.processing.impl.ResolverImpl.getSymbolsWithAnnotation(ResolverImpl.kt:274)
	at com.google.devtools.ksp.processing.Resolver$DefaultImpls.getSymbolsWithAnnotation$default(Resolver.kt:49)
	at dev.zacsweers.moshix.ksp.JsonClassSymbolProcessor.process(JsonClassSymbolProcessor.kt:105)
t
Thanks for reporting this. It definitely looks like a bug in KSP. Let me try if I can figure out anything before requesting repro.
👍 1
The crash happened deep in the compiler so I'm trying to reproduce. With the branch
z/updates
, I tried
:moshi-ksp:tests:test
and also
test
but no luck. Could you show me how to reproduce?
z
Run the tests in
JsonClassSymbolProcessorTest.kt
🙏 1
t
Still passing. Aren't those parts of
:moshi-ksp:moshi-ksp:test
? I ran them in IntelliJ and this is what IntelliJ did:
:moshi-ksp:moshi-ksp:test --tests "dev.zacsweers.moshix.ksp.JsonClassSymbolProcessorTest"
Just in case, this is the branch I'm using: https://github.com/ZacSweers/MoshiX/tree/z/updates
z
weird, that’s what I run and get those failures locally 🤔
does it happen if you run from command line?
t
Unfortunately, it's passing from command line as well. Could there be any environment variables that matter?
I also tried killing all java processes and cleared gradle cache but still no luck
z
let me try again
ok one more thing
try adding
moshix.useKsp=true
to gradle.properties
I've updated the PR with a bunch of work to bring it up to Kotlin 1.5 and requires JDK 11+
t
Unfortunately, still unable to repro. Also tried the command in `.github/workflow/ci.yml`:
./gradlew build check -Pmoshix.useKsp=true -Pksp.incremental=(true|false) --stacktrace
Can this be reproduced reliably, or does it happen intermittently? If it's the latter, I need to figure out a way to embed some more useful logs...
If this is easily reproducible, let me ask Jiaxiang for help.
z
super strange, I don’t know what else it could be. It reproduces on CI and I can reproduce it easily across two different computers
t
There must be something wrong in my steps 😞 Can you point me to the CI log?
z
same on command line too running
./gradlew check
CI links are at the bottom of the PR - https://github.com/ZacSweers/MoshiX/pull/107. Interestingly, they have a different error, a NoSuchMethodError https://github.com/ZacSweers/MoshiX/pull/107/checks?check_run_id=2488465401
t
The NoSuchMethodError is likely due to mismatch of KSP and Kotlin version (1.4.32 vs 1.5)
z
I’m using KSP 1.5.0-1.0.0-alpha09
t
but the kotlin version is 1.4.32 in the log?
z
I don’t know why 🤔
ah I see why
leftover override in CI
updated the PR, now it should be the issues I’m seeing locally
t
thanks, let me try again by copying the commands in CI. I was suspecting whether it could be mac vs linux, but the CI seems to run in linux.
z
yeah, and my local setup is mac. CI is giving me lots of different failures depending on the JDK, gradle makes this tough 😞
t
@Jiaxiang confirmed that it is reproducible on mac, but not his linux machine. 😢
j
I will be looking into this
🙏 2
z
lmk if there's a PR or issue I could follow for this
Any chance this was fixed in 1.5.0-1.0.0-alpha10?
j
Unfortunately I was packed up in the last release, I will fix this in the next release.
👍 1
created an issue for your tracking: https://github.com/google/ksp/issues/427
👍 1
I was not able to fix this, I’ve updated my findings in the issues for tracking, will keep looking to see if I can find the cause in next release.
How do I make Moshi-ksp to run my locally built KSP? I tried to change the version in Dependencies.kt and added mavenLocal() to the build.gradle.kts as well as setting.gradle.kts in project root but it is still saying not able to find my KSP version.
z
I haven't tried but it should be something like this: • Install a local version to maven local, say version
HEAD-LOCAL
• Change the KSP version in moshix's Dependencies.kt to
HEAD-LOCAL
• Add
mavenLocal()
to all the
repositories
blocks in build files.
buildSrc/build.gradle.kts
,
/settings.gradle.kts
,
/build.gradle.kts
That should do it. Make sure that when installing locally you also install the gradle plugin and its plugin marker