https://kotlinlang.org logo
#scripting
Title
# scripting
s

Sebastian Schuberth

12/07/2023, 3:45 PM
Any idea (no puh intended) what I can do if IDEA is not showing my custom script definitions (that are part of the current project) in the settings? See
It used to show my own "rules.kts" script extension, but now it doesn't anymore. I've updated a bunch of dependencies since then (Gradle 8.5, Kotlin 1.9.21), could that play a role?
Ah, subtle, the status bar shows > No script runtime was found in the classpath: class 'kotlin.script.templates.standard.ScriptTemplateWithArgs' not found. Please add kotlin-script-runtime.jar to the module dependencies. Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly. I need to find out what that means.
I have dependencies on these, which I thought would suffice:
Copy code
implementation("org.jetbrains.kotlin:kotlin-scripting-common")
    implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host")
d

Daniel Pitts

12/07/2023, 10:57 PM
I found that if IDEA has an error while loading the project, it will just silently swallow it and won't try to reload the script template without restarting. You can see these types of errors in he Idea.log (
Show log
from the
Help
menu).
After you solve the problem in that log, restart IntelliJ, and it should pick it up.
i

Ilya Muradyan

12/08/2023, 12:47 AM
Just in case, you can try disabling this Registry flag (in 23.3) kotlin.scripting.load.definitions.on.demand There is a known regression that may prevent custom script definitions from loading
👍🏻 1
s

Sebastian Schuberth

12/08/2023, 6:57 AM
Thanks @Ilya Muradyan, disabling that flag indeed did fix the issue!
If it's known, is there an issue I can track for the fix?
i

Ilya Muradyan

12/08/2023, 8:42 AM
Sure: https://youtrack.jetbrains.com/issue/KTIJ-27995 The fix is ready and should be backported to 2023.3.1
👍🏻 1
s

Sebastian Schuberth

12/08/2023, 8:46 AM
Ah, it has already been fixed (though not released yet), great!