ksp: Incremental compilation fails with "Number of loaded files in snapshots differs"

We are building support for KSP in Micronaut (a popular Java/Kotlin framework). The initial implementation is done but it fails with KSP incremental compilation enabled with an error “Number of loaded files in snapshots differs” on the second compile:

./gradlew test
> Task :kspKotlin FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':kspKotlin'.
> Number of loaded files in snapshots differs. Reported changed files: []

To reproduce download this example project and run ./gradlew cTK twice.

ksp-test2.zip

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 11
  • Comments: 28 (2 by maintainers)

Most upvoted comments

hot fix is released as 1.8.20-1.0.11, closing this issue.

Same issue here. We run our Jenkins CI builds without any caching in place, so 100% clean build each time. After updating to Kotlin 1.8.20, KSP 1.8.20-1.0.10 and Compose compiler 1.4.5 we also see this build error.

Cool, hot-fix release should be available on Monday.

Hi all, thanks for the reports, I’ve pushed a fix in #1363 and it is now available as 1.8.20-1.0.11-SNAPSHOT in snapshot repository, you can add

  maven {
    url = uri("https://oss.sonatype.org/content/repositories/snapshots")
  }

in your project and try out this snapshot to see if it resolves your issue, if everything looks good I will do a hot fix release soon to address this issue.

I’m facing the same issue since upgrading to Kotlin 1.8.20 and KSP 1.8.20-1.0.10. Interestingly I cannot reproduce this on my local machine but 100% in a GitHub Actions workflow, although the workspace is absolutely clean with no caches (I disabled the cache action to ensure this).

I also encountered this problem when using 1.8.20-1.0.10, Need to run gradle clean before run the project each time

yes #1350 was included in the release, but does not seem to fix the issue.

@neetopia did #1350 make it into 1.8.20-1.0.10? I’m still reproducing this in that release now in https://github.com/slackhq/circuit/pull/454.

100% reproducible with the below steps

  1. run ./gradlew check
  2. make a small change to a source test file, such as adding a println in PetListSnapshotTest.kt
  3. run ./gradlew check again
  4. 💥

So glad I found this issue… we couldn’t run after updating to Kotlin 1.8.20, KSP 1.8.20-1.0.10 and Compose compiler 1.4.5.

We just tried the 1.8.20-1.0.11-SNAPSHOT and all is working for us! (hope 1.8.20-1.0.11 releases soon 😃 )

We can’t do a back port release, would disable incremental to mitigate this issue work for you?

@Enaium can you give me a reproduce project? I am not able to reproduce @ZacSweers 's sample anymore after manually removing home caches and project configuration caches. Right now I am not sure if that has anything to do with remote cache.

https://github.com/Enaium/jimmer-sql-kt-vertx But the project is using 1.8.10-1.0.9 now

Sorry for not being able to test this, I did not found enough time to test it yet. Though it still happens on Kotlin 1.8.20 and KSP 1.8.20-1.0.10. https://github.com/SimonMarquis/nowinandroid/actions/runs/4600305482/jobs/8126733329#step:9:2079

It might very well be an issue with the non-statble (non-compatible?) Compose compiler 1.4.4-dev-k1.8.20-RC-88d9f3a8232.