Issue in init.gradle with ktlint-gradle when run script

initscript {
    repositories {
        maven("https://plugins.gradle.org/m2/")
    }

    dependencies {
         classpath("org.jlleitschuh.gradle:ktlint-gradle:12.1.1")
    }
}

rootProject {
    allprojects {
        apply<org.jlleitschuh.gradle.ktlint.KtlintPlugin>()
        // Optionally configure plugin
        extensions.configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
            debug.set(true)
            verbose.set(true)
            android.set(true)
            outputToConsole.set(true)
            outputColorName.set("RED")
            ignoreFailures.set(false)

            reporters {
                reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE)
                reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.HTML)
            }

            filter {
                exclude("**/generated/**")
                include("**/kotlin/**")
            }
        }
    }
}

when run this command line ./gradlew --init-script gradle/init.gradle.kts

Calculating task graph as configuration cache cannot be reused because init script 'gradle/init.gradle.kts' has changed.
Type-safe project accessors is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension
> org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension

Did you follow the suggestion in the error message?
If not, why not?
If yes, what is the result? (Especially of --stacktrace or better --scan)

thank you for replay, when apply scan

Auto-applied by using --scan

* What went wrong:
Error resolving plugin [id: 'com.gradle.enterprise', version: '3.15.1', artifact: 'com.gradle:gradle-enterprise-gradle-plugin:3.15.1']
> Build completed with 1 failures.
   > org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension

Well, in this case --scan is not better as you also have a problem to find the according plugin.