Inspectopedia 2026.3 Help

Using .main.kts annotation in plain .kts script

Reports the @DependsOn, @Repository, and @Import annotations when they are used in a plain Kotlin script (.kts) rather than a main Kotlin script (.main.kts).

These annotations are contributed only by the main Kotlin Scripting definition, so they are supported exclusively in .main.kts files. A plain .kts script has no functionality that processes them: the references do not resolve, and the dependencies or script imports they would declare never take effect.

The quick fix renames the file to .main.kts, which switches the script definition so that the annotations resolve and work as intended.

@file:DependsOn("com.example:my-library:1.0") @file:Import("helper.main.kts") // In a plain .kts script these annotations are unresolved and have no effect. println("Hello")

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

MainKtsAnnotationUsageInPlainKts
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Kotlin | Probable bugs

If you do not actually need external dependencies, you can keep the file as a plain .kts script and remove the annotations instead.

Inspection ID: MainKtsAnnotationUsageInPlainKts

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection MainKtsAnnotationUsageInPlainKts

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2026.3, Qodana for JVM 2026.3,

Last modified: 20 November 2026