Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public val PluginDependenciesSpec.base: PluginDependencySpec defined in org.gradle.kotlin.dsl

I have a project with composite builds with Gradle 8.10.2.
In the root build.gradle.kts:

plugins {
    base
}
...

When running a Gradle task I sometimes get:

2025-03-18T05:55:04.499674Z 01O > Configure project :
2025-03-18T05:55:04.499693Z 01O e: file:///builds/***/build.gradle.kts:2:5: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
2025-03-18T05:55:04.499713Z 01O public val PluginDependenciesSpec.base: PluginDependencySpec defined in org.gradle.kotlin.dsl
2025-03-18T05:55:04.499723Z 01O e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
2025-03-18T05:55:04.499737Z 01O     class org.gradle.kotlin.dsl.PluginDependenciesSpecScope, unresolved supertypes: org.gradle.plugin.use.PluginDependenciesSpec
2025-03-18T05:55:04.499756Z 01O Adding -Xextended-compiler-checks argument might provide additional information.
2025-03-18T05:55:04.499769Z 01O 
2025-03-18T05:55:04.499776Z 01O 
2025-03-18T05:55:04.499788Z 01O FAILURE: Build failed with an exception.
2025-03-18T05:55:04.499793Z 01O 
2025-03-18T05:55:04.499800Z 01O * Where:
2025-03-18T05:55:04.499812Z 01O Build file '/builds/***/build.gradle.kts' line: 2
2025-03-18T05:55:04.499817Z 01O 
2025-03-18T05:55:04.499824Z 01O * What went wrong:
2025-03-18T05:55:04.499838Z 01O Script compilation errors:
2025-03-18T05:55:04.499845Z 01O 
2025-03-18T05:55:04.499859Z 01O   Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
2025-03-18T05:55:04.499875Z 01O       class org.gradle.kotlin.dsl.PluginDependenciesSpecScope, unresolved supertypes: org.gradle.plugin.use.PluginDependenciesSpec
2025-03-18T05:55:04.499883Z 01O   Adding -Xextended-compiler-checks argument might provide additional information.
2025-03-18T05:55:04.499891Z 01O   
2025-03-18T05:55:04.499899Z 01O 
2025-03-18T05:55:04.499906Z 01O   Line 2:     base
2025-03-18T05:55:04.499919Z 01O               ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
2025-03-18T05:55:04.499940Z 01O                   public val PluginDependenciesSpec.base: PluginDependencySpec defined in org.gradle.kotlin.dsl
2025-03-18T05:55:04.499945Z 01O 
2025-03-18T05:55:04.499953Z 01O 2 errors
2025-03-18T05:55:04.499967Z 01O 
2025-03-18T05:55:04.499977Z 01O * Try:
2025-03-18T05:55:04.499984Z 01O > Run with --info or --debug option to get more log output.
2025-03-18T05:55:04.499993Z 01O > Run with --scan to get full insights.
2025-03-18T05:55:04.500013Z 01O > Get more help at https://help.gradle.org.
2025-03-18T05:55:04.500018Z 01O 
2025-03-18T05:55:04.500025Z 01O * Exception is:
2025-03-18T05:55:04.500040Z 01O ScriptCompilationException(scriptCompilationErrors=[ScriptCompilationError(message=Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
2025-03-18T05:55:04.500104Z 01O public val PluginDependenciesSpec.base: PluginDependencySpec defined in org.gradle.kotlin.dsl, location=/builds/***/.gradleHome/.tmp/gradle-kotlin-dsl-14778130009821908000.tmp/build.gradle.kts (2:5)), ScriptCompilationError(message=Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
2025-03-18T05:55:04.500121Z 01O     class org.gradle.kotlin.dsl.PluginDependenciesSpecScope, unresolved supertypes: org.gradle.plugin.use.PluginDependenciesSpec
2025-03-18T05:55:04.500135Z 01O Adding -Xextended-compiler-checks argument might provide additional information.
2025-03-18T05:55:04.500141Z 01O , location=null)])
2025-03-18T05:55:04.500149Z 01O 	at org.gradle.kotlin.dsl.support.KotlinCompilerKt.compileKotlinScriptModuleTo(KotlinCompiler.kt:191)
2025-03-18T05:55:04.500167Z 01O 	at org.gradle.kotlin.dsl.support.KotlinCompilerKt.compileKotlinScriptToDirectory(KotlinCompiler.kt:149)
2025-03-18T05:55:04.500180Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$compileScript$1.invoke(ResidualProgramCompiler.kt:713)
2025-03-18T05:55:04.500191Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$compileScript$1.invoke(ResidualProgramCompiler.kt:712)
2025-03-18T05:55:04.500208Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost$runCompileBuildOperation$1.call(KotlinScriptEvaluator.kt:187)
2025-03-18T05:55:04.500216Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost$runCompileBuildOperation$1.call(KotlinScriptEvaluator.kt:184)
2025-03-18T05:55:04.500228Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
2025-03-18T05:55:04.500248Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
2025-03-18T05:55:04.500262Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2025-03-18T05:55:04.500275Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.500288Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
2025-03-18T05:55:04.500297Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.500307Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
2025-03-18T05:55:04.500320Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.runCompileBuildOperation(KotlinScriptEvaluator.kt:184)
2025-03-18T05:55:04.500329Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter$compile$1$1$1$1.invoke(Interpreter.kt:334)
2025-03-18T05:55:04.500345Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter$compile$1$1$1$1.invoke(Interpreter.kt:334)
2025-03-18T05:55:04.500361Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.compileScript-C5AE47M(ResidualProgramCompiler.kt:712)
2025-03-18T05:55:04.500370Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.compileStage1-EfyMToc(ResidualProgramCompiler.kt:695)
2025-03-18T05:55:04.500380Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.compilePlugins-A6FCAhw(ResidualProgramCompiler.kt:555)
2025-03-18T05:55:04.500394Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.emitCompiledPluginsBlock(ResidualProgramCompiler.kt:383)
2025-03-18T05:55:04.500402Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.emit(ResidualProgramCompiler.kt:197)
2025-03-18T05:55:04.500464Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.emit(ResidualProgramCompiler.kt:182)
2025-03-18T05:55:04.500481Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.access$emit(ResidualProgramCompiler.kt:83)
2025-03-18T05:55:04.500505Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$emitDynamicProgram$1$1.invoke(ResidualProgramCompiler.kt:123)
2025-03-18T05:55:04.500520Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$emitDynamicProgram$1$1.invoke(ResidualProgramCompiler.kt:121)
2025-03-18T05:55:04.500537Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$overrideExecute$1.invoke(ResidualProgramCompiler.kt:548)
2025-03-18T05:55:04.500550Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$overrideExecute$1.invoke(ResidualProgramCompiler.kt:547)
2025-03-18T05:55:04.500578Z 01O 	at org.gradle.kotlin.dsl.support.bytecode.AsmExtensionsKt.method(AsmExtensions.kt:133)
2025-03-18T05:55:04.500587Z 01O 	at org.gradle.kotlin.dsl.support.bytecode.AsmExtensionsKt.publicMethod(AsmExtensions.kt:116)
2025-03-18T05:55:04.500600Z 01O 	at org.gradle.kotlin.dsl.support.bytecode.AsmExtensionsKt.publicMethod$default(AsmExtensions.kt:108)
2025-03-18T05:55:04.500609Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.overrideExecute(ResidualProgramCompiler.kt:547)
2025-03-18T05:55:04.500619Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.access$overrideExecute(ResidualProgramCompiler.kt:83)
2025-03-18T05:55:04.500632Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$emitDynamicProgram$1.invoke(ResidualProgramCompiler.kt:121)
2025-03-18T05:55:04.500643Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$emitDynamicProgram$1.invoke(ResidualProgramCompiler.kt:119)
2025-03-18T05:55:04.500653Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$program$3.invoke(ResidualProgramCompiler.kt:673)
2025-03-18T05:55:04.500666Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler$program$3.invoke(ResidualProgramCompiler.kt:671)
2025-03-18T05:55:04.500674Z 01O 	at org.gradle.kotlin.dsl.support.bytecode.AsmExtensionsKt.publicClass-7y5yvvE(AsmExtensions.kt:41)
2025-03-18T05:55:04.500706Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.program-5oOsWEo(ResidualProgramCompiler.kt:671)
2025-03-18T05:55:04.500722Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.access$program-5oOsWEo(ResidualProgramCompiler.kt:83)
2025-03-18T05:55:04.500731Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.emitDynamicProgram(ResidualProgramCompiler.kt:798)
2025-03-18T05:55:04.500741Z 01O 	at org.gradle.kotlin.dsl.execution.ResidualProgramCompiler.compile(ResidualProgramCompiler.kt:102)
2025-03-18T05:55:04.500754Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter$compile$1.invoke(Interpreter.kt:337)
2025-03-18T05:55:04.500761Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter$compile$1.invoke(Interpreter.kt:301)
2025-03-18T05:55:04.500771Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$KotlinScriptCompilationAndInstrumentation.compile(KotlinScriptEvaluator.kt:409)
2025-03-18T05:55:04.500785Z 01O 	at org.gradle.internal.scripts.BuildScriptCompilationAndInstrumentation.execute(BuildScriptCompilationAndInstrumentation.java:95)
2025-03-18T05:55:04.500794Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:105)
2025-03-18T05:55:04.500803Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:44)
2025-03-18T05:55:04.500861Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:59)
2025-03-18T05:55:04.500869Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:56)
2025-03-18T05:55:04.500880Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
2025-03-18T05:55:04.500893Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
2025-03-18T05:55:04.501124Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2025-03-18T05:55:04.501147Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.501159Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
2025-03-18T05:55:04.501172Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.501180Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
2025-03-18T05:55:04.501190Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:56)
2025-03-18T05:55:04.501207Z 01O 	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
2025-03-18T05:55:04.501215Z 01O 	at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:42)
2025-03-18T05:55:04.501228Z 01O 	at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:75)
2025-03-18T05:55:04.501236Z 01O 	at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
2025-03-18T05:55:04.501247Z 01O 	at org.gradle.internal.execution.steps.PreCreateOutputParentsStep.execute(PreCreateOutputParentsStep.java:50)
2025-03-18T05:55:04.501261Z 01O 	at org.gradle.internal.execution.steps.PreCreateOutputParentsStep.execute(PreCreateOutputParentsStep.java:28)
2025-03-18T05:55:04.501270Z 01O 	at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:61)
2025-03-18T05:55:04.501281Z 01O 	at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:26)
2025-03-18T05:55:04.501295Z 01O 	at org.gradle.internal.execution.steps.NoInputChangesStep.execute(NoInputChangesStep.java:30)
2025-03-18T05:55:04.501303Z 01O 	at org.gradle.internal.execution.steps.NoInputChangesStep.execute(NoInputChangesStep.java:21)
2025-03-18T05:55:04.501314Z 01O 	at org.gradle.internal.execution.steps.CaptureOutputsAfterExecutionStep.execute(CaptureOutputsAfterExecutionStep.java:69)
2025-03-18T05:55:04.501327Z 01O 	at org.gradle.internal.execution.steps.CaptureOutputsAfterExecutionStep.execute(CaptureOutputsAfterExecutionStep.java:46)
2025-03-18T05:55:04.501336Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:189)
2025-03-18T05:55:04.501346Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.executeAndStoreInCache(BuildCacheStep.java:145)
2025-03-18T05:55:04.501365Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.lambda$executeWithCache$4(BuildCacheStep.java:101)
2025-03-18T05:55:04.501374Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.lambda$executeWithCache$5(BuildCacheStep.java:101)
2025-03-18T05:55:04.501384Z 01O 	at org.gradle.internal.Try$Success.map(Try.java:175)
2025-03-18T05:55:04.501396Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.executeWithCache(BuildCacheStep.java:85)
2025-03-18T05:55:04.501404Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$0(BuildCacheStep.java:74)
2025-03-18T05:55:04.501414Z 01O 	at org.gradle.internal.Either$Left.fold(Either.java:115)
2025-03-18T05:55:04.501427Z 01O 	at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:62)
2025-03-18T05:55:04.501434Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73)
2025-03-18T05:55:04.501462Z 01O 	at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48)
2025-03-18T05:55:04.501483Z 01O 	at org.gradle.internal.execution.steps.NeverUpToDateStep.execute(NeverUpToDateStep.java:34)
2025-03-18T05:55:04.501492Z 01O 	at org.gradle.internal.execution.steps.NeverUpToDateStep.execute(NeverUpToDateStep.java:22)
2025-03-18T05:55:04.501503Z 01O 	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
2025-03-18T05:55:04.501529Z 01O 	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
2025-03-18T05:55:04.501540Z 01O 	at org.gradle.internal.execution.steps.ResolveNonIncrementalCachingStateStep.executeDelegate(ResolveNonIncrementalCachingStateStep.java:50)
2025-03-18T05:55:04.501552Z 01O 	at org.gradle.internal.execution.steps.AbstractResolveCachingStateStep.execute(AbstractResolveCachingStateStep.java:71)
2025-03-18T05:55:04.501567Z 01O 	at org.gradle.internal.execution.steps.AbstractResolveCachingStateStep.execute(AbstractResolveCachingStateStep.java:39)
2025-03-18T05:55:04.501576Z 01O 	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:107)
2025-03-18T05:55:04.501585Z 01O 	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:56)
2025-03-18T05:55:04.501622Z 01O 	at org.gradle.internal.execution.steps.AbstractCaptureStateBeforeExecutionStep.execute(AbstractCaptureStateBeforeExecutionStep.java:64)
2025-03-18T05:55:04.501633Z 01O 	at org.gradle.internal.execution.steps.AbstractCaptureStateBeforeExecutionStep.execute(AbstractCaptureStateBeforeExecutionStep.java:43)
2025-03-18T05:55:04.501649Z 01O 	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
2025-03-18T05:55:04.501659Z 01O 	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$executeInTemporaryWorkspace$3(AssignImmutableWorkspaceStep.java:209)
2025-03-18T05:55:04.501670Z 01O 	at org.gradle.internal.execution.workspace.impl.CacheBasedImmutableWorkspaceProvider$1.withTemporaryWorkspace(CacheBasedImmutableWorkspaceProvider.java:119)
2025-03-18T05:55:04.501702Z 01O 	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.executeInTemporaryWorkspace(AssignImmutableWorkspaceStep.java:199)
2025-03-18T05:55:04.501713Z 01O 	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$execute$0(AssignImmutableWorkspaceStep.java:121)
2025-03-18T05:55:04.501724Z 01O 	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.execute(AssignImmutableWorkspaceStep.java:121)
2025-03-18T05:55:04.501737Z 01O 	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.execute(AssignImmutableWorkspaceStep.java:90)
2025-03-18T05:55:04.501746Z 01O 	at org.gradle.internal.execution.steps.ChoosePipelineStep.execute(ChoosePipelineStep.java:38)
2025-03-18T05:55:04.501756Z 01O 	at org.gradle.internal.execution.steps.ChoosePipelineStep.execute(ChoosePipelineStep.java:23)
2025-03-18T05:55:04.501771Z 01O 	at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.lambda$execute$2(ExecuteWorkBuildOperationFiringStep.java:67)
2025-03-18T05:55:04.501781Z 01O 	at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:67)
2025-03-18T05:55:04.501794Z 01O 	at org.gradle.internal.execution.steps.ExecuteWorkBuildOperationFiringStep.execute(ExecuteWorkBuildOperationFiringStep.java:39)
2025-03-18T05:55:04.501807Z 01O 	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:46)
2025-03-18T05:55:04.501815Z 01O 	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:34)
2025-03-18T05:55:04.501825Z 01O 	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:48)
2025-03-18T05:55:04.501843Z 01O 	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:35)
2025-03-18T05:55:04.501852Z 01O 	at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:61)
2025-03-18T05:55:04.501862Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.cachedDirFor(KotlinScriptEvaluator.kt:279)
2025-03-18T05:55:04.501876Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter.compile(Interpreter.kt:301)
2025-03-18T05:55:04.501884Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter.emitSpecializedProgramFor(Interpreter.kt:267)
2025-03-18T05:55:04.501905Z 01O 	at org.gradle.kotlin.dsl.execution.Interpreter.eval(Interpreter.kt:199)
2025-03-18T05:55:04.501919Z 01O 	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator.evaluate(KotlinScriptEvaluator.kt:125)
2025-03-18T05:55:04.501927Z 01O 	at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:46)
2025-03-18T05:55:04.501937Z 01O 	at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:43)
2025-03-18T05:55:04.501950Z 01O 	at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:35)
2025-03-18T05:55:04.501958Z 01O 	at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:68)
2025-03-18T05:55:04.501969Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2025-03-18T05:55:04.501982Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2025-03-18T05:55:04.501991Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2025-03-18T05:55:04.502001Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.502017Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
2025-03-18T05:55:04.502026Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2025-03-18T05:55:04.502040Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
2025-03-18T05:55:04.502048Z 01O 	at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(BuildOperationScriptPlugin.java:65)
2025-03-18T05:55:04.502059Z 01O 	at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
2025-03-18T05:55:04.502073Z 01O 	at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:65)
2025-03-18T05:55:04.502083Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$1(DefaultProjectStateRegistry.java:411)
2025-03-18T05:55:04.502095Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:429)
2025-03-18T05:55:04.502109Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:410)
2025-03-18T05:55:04.502118Z 01O 	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:46)
2025-03-18T05:55:04.502128Z 01O 	at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:27)
2025-03-18T05:55:04.502142Z 01O 	at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:35)
2025-03-18T05:55:04.502151Z 01O 	at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:109)
2025-03-18T05:55:04.502162Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$1(DefaultProjectStateRegistry.java:411)
2025-03-18T05:55:04.502180Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$fromMutableState$2(DefaultProjectStateRegistry.java:434)
2025-03-18T05:55:04.502202Z 01O 	at org.gradle.internal.work.DefaultWorkerLeaseService.withReplacedLocks(DefaultWorkerLeaseService.java:359)
2025-03-18T05:55:04.502218Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:434)
2025-03-18T05:55:04.502228Z 01O 	at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:410)
2025-03-18T05:55:04.502279Z 01O 	at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:100)
2025-03-18T05:55:04.502297Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2025-03-18T05:55:04.502305Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2025-03-18T05:55:04.502316Z 01O 	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
....

Why is this happening?

Never seen that.
Sounds to me like you should open a bug report.

Another strange error

build.gradle.kts:1:1: Cannot access implicit script receiver class 'org.gradle.api.Project'. Check your module classpath for missing or conflicting dependencies

Also I should mention that there are next gradle properties:

org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=false

The latter is most probably just wasting your time by using a one-off daemon on each invocation instead of reusing daemons.
But I don’t think these properties are related to the problem(s).

Also this other error sounds like you should report it, but maybe it is the same error.
Either way, you probably will need an MCVE or the Gradle folks will probably not be able to do much about that.

It’s hard to reproduce. These issues only occur in CI, and I found a bug with the same errors. I removed org.gradle.caching=true and am monitoring the issues.

Ah, I see, but I don’t think org.gradle.caching will have any influence on that if that is the issue you are seeing.
org.gradle.caching is about caching task outputs and artifact transform outputs.
I highly doubt it will have any effect on that generated Gradle API jar.

2025-03-20T12:05:33.309165Z 01O > Configure project :
2025-03-20T12:05:33.309178Z 01O Evaluating root project '***' using build file '/builds/***/build.gradle.kts'.
2025-03-20T12:05:33.309199Z 01O Build cache key for Kotlin DSL script compilation (Project/TopLevel/stage1) is 5bb051ae48ce99bf6c2***9bd069eaf4

I turned on INFO log level for the Gradle.
Why I see message about Build cache key for Kotlin DSL script compilation how to totally disable it?

I don’t know whether you can.
But whether you can or not does not really make much difference.
As I said, the cache of the build script compilation is not the problem.
The compiling of the build script does not work due to a broken generated jar.
And that generated jar is not “cached”, it is just generated if it is not present.
And according to the issue you dug up, if the build is aborted at an unlucky moment that jar gets corrupted.

I reported a bug and created a project to reproduce an issue.
Run build.sh and wait for a few hours …

1 Like