Hi there! I got a new problem/question with the la...
# scripting
o
Hi there! I got a new problem/question with the latest IntelliJ 2026.1.1 - I am using my own script definition in my project and in former versions of IntelliJ, the "Kotlin scripting" dialog had a very important button "Scan classpath" when my own definition for my script type was missing. This button has disappeared, just like my script definition has. How can I scan my classpath now to activate my scripting language? I had to restart and invalidate caches - that's when my formerly working script definition disappeared.... :-(
Ok, I found it - but it still does not work. The button is hidden underneath "custom definitions" and is renamed - its real purpose is not the button text anymore, but the light gray text underneath... From the UX perspective it's quite a bad move, if you ask me. However, my troubles are not solved. My custom script definition includes a set of automatically imported elements - and even after it is back in the list, the editors show errors due to missing imports... so, something is broken.
Also, every time I restart IntelliJ, my own script definition is lost again. I need to always re-enter this dialog and press the search definitions button again. Then my scripts are shown to be correctly detected, but their default imports still don't work. This is so frustrating!
@ilya.chernikov @Vladislav Koshkin maybe you can help?
This is SO damn weird: for SOME files, my script type's import do work, in other files it does not. Both show the very same script definition in the lower right panel. Closing/reoperning does not help, neither for that one editor nor for the whole project. And everytime I reopen the project, the script definition is lost again and I need to go to that dialog...
I had to do a "real orchestrated" flow to get it back to somehow work now. But this cannot by all means be "normal" and wanted: I had to: • close all other projects • close ALL editor windows in my project • Invalidate Caches... -> Invalidate and restart • Wait for project to load • Then: Kotlin Scripting | Search definitions • Then: open the first script file again If you deviate from this procedure, e.g. leave an editor open, the opened file WILL NOT RECOVER and still don't work. When the project is closed and reopened, I fear that it will again lose its script definition. IntelliJ 2026.1.1 is broken regarding custom script definitions!
Here it gets even more absurd: even though the imports function well, I get these hints whether I would like to add an import anyhow... Why?
m
Unfortunately Kotlin Scripting has always had such bugs. I don't know why but the implementation is very prone to incorrectly caching things, semi-random resolution failures and more. It's such a pity, as Kotlin Scripting works great otherwise and I've got a lot of mileage out of it. It could be a great competitor to Python if these details were fixed up
v
I'm gonna process all these by the end of the week and I'll create a couple of issues (if they are not fixed yet for 26.2)
anyway I'll try make fixes on time for the upcoming 26.2 release (july)
hi, sorry for the radio silence https://youtrack.jetbrains.com/issue/KTIJ-38886 I merged all the fixes just now. let's wait for the next EAP version to be released (next week I guess)
m
Nice! Does this change anything w.r.t. IDE plugins that offer scripting host classpaths?
v
I don't think so: it's a separate mechanism, but I'll double check
Hi, EAP is released: custom script definition should survive between relaunches now; @Olaf Gottschalk @martmists I'd like you to try it asap so I can do fixes (if there is need) till the next EAP also right now I'm cooking a robust inspection on classes marked
@KotlinScript
files, so you don't have to guess what to do
👍 3
o
Thanks, Vlad! Will do!
Next week earliest though
m
@Vladislav Koshkin Thank you for looking into this! Unfortunately, EAP still struggles to load definitions. Potentially relevant log snippets:
Copy code
2026-05-31 10:15:16,629 [  29281]   WARN - #c.i.o.o.e.ConfigurableExtensionPointUtil - ignore configurable with duplicated id: instant.run
2026-05-31 10:15:16,672 [  29324]   INFO - #c.i.o.p.DumbServiceImpl - exit dumb mode [intercept]
2026-05-31 10:15:16,753 [  29405]   WARN - #c.i.o.o.e.ConfigurableExtensionPointUtil - ignore deprecated groupId: language for id: preferences.language.Kotlin.scripting
2026-05-31 10:15:16,768 [  29420]   INFO - #c.i.w.i.i.WorkspaceModelImpl - Workspace model update attempt 1/3, updater took 7 ms: The Gradle project sync
  phase = SCRIPT_MODEL_PHASE
  taskId = RESOLVE_PROJECT:0
  projectPath = /home/mart/git/kotlin/intercept-kotlin  (project=intercept, locationHash=b88f1125)
...
2026-05-31 10:15:56,958 [  69610]   INFO - #o.j.k.i.script - [KOTLIN_SCRIPTING] Loading script definitions: classes=[com.intercept.script.WebScript, com.intercept.script.GameScript], classpath=[<correct classpath as far as I can tell, source directories for the two classes are there just fine>]
2026-05-31 10:15:56,963 [  69615]   INFO - #o.j.k.i.script - [KOTLIN_SCRIPTING] Loaded definition=Web Script}
2026-05-31 10:15:56,970 [  69622]   INFO - #o.j.k.i.script - [KOTLIN_SCRIPTING] Loaded definition=Game Script}
Screenshot_20260531_101600.png
Looks like after each edit to the script definitions, the following needs to happen: Build jar -> Register custom scripts -> Invalidate caches -> Register custom scripts before Gradle is done importing -> Hope it works (seems to work about 25% of the time so far?) Leaving out any of these steps makes it not load for me.
v
Register custom scripts -> Invalidate caches -> Register custom scripts before Gradle is done importing
there is an action "Reload Script Configuration" when you right click in editor. It should drop the definition caches making the engine to load definition from .jar again. can you check if it works for you?
m
That does seem to work, though editing the definition and re-jarring still requires a restart to be reloaded by IJ it seems, even when reloading the configuration.
o
@Vladislav Koshkin sorry for late response, I was on vacation and just started to look at the changes today. I updated to the latest available EAP and re-opened my projects in that version. First surprise: now I have to name a class or even a jar to add my definition to IntelliJ. Formerly, I was under the impression that IF that currently opened project has some script definitions embedded, I could simply scan for them and they are automatically found. Now it's manual work. Does this setup then "survive" and is available in all opened projects and does it stay over the course of opening and closing projects? In other words: is this a persistent configuration rather than a per-project thing? Next, I was looking for the information of which script IntelliJ thinks it is looking at. Found something at the top of the editor now: is that the new position? Regarding stability: I still have script files that are totally correct in syntax, file suffix, etc and they get detected properly as my script type: but they still stay full of errors due to missing auto-imports. Those imports work fine in many other scripts, but those that are erroneous, stay like this and I don't know how to "reset" them individually. I tried closing the editor, restarting IntelliJ, reopening this script, but the problem stays. When I manually add import statements, it works, but that should not be needed and is not needed in other scripts. I don't understand this.
Sadly, another restart revealed: my Kotlin Scripting setup is gone again. So it's not persistent. This is really, really annoying. 😞
and: its' completely inconsistent now. One editor that worked before is still error-free, even though my script definition is lost:
Here it is: it should be .trala.kts script, not .kts script!
The other one that never worked, still does not work:
And the settings are now completely weird and inconsistent: my script definition is missing again in the list, its class is still mentioned in the input box, but I cannot "Apply" it or load it in any way that seems logical:
It gets even weirder: when I REMOVE the name of my script definition and then press Apply, THEN it comes back to the list of loaded script definitions!!!
@Vladislav Koshkin any news regarding my findings?
@Vladislav Koshkin now that IntelliJ has been released... how do I fix my scripting now? It simply does not work as it used to. I am kind of extremely disappointed. My script definition is NOT found, no matter what I put into those fields. I put the name of the definition class AND a fully qualified path to the jar file. Hit Apply. No error, but nothing found. Why?? Please assist me.
I really tried to give you those hints prior to release, but there were no answers...
So, I got my DSL definition library - it's a separate jar file with its definition class. It's a dependency to other projects. But in those other projects, the definition is never found.
loading 1
v
Hi, I'm with you. Can you remind me the project structure? it should work when apply is clicked. is there anything in the log? did you build the .jar that has definition?
o
Nothing fancy. The transformation-dsl lib is a direct dependency. Here's the view on it in the project view:
v
by the way there is a inspection now on the definition class. it should automatically add the classpath needed to the settings, can you also give it a try?
o
I tried all combinations: both fields filled. Then only the class, then only the jar. Nothing works. I don't like this dialog and the UX at all. It is not logical. You fill fields, you press Apply. Nothing happens and you don't know why. You don't know if it's your fault (bad field values), if it's the lib's fault. Nothing.
Is this global or per project? Now I realize it does not even work in the project itself. 😞
And how does all this relate to these text files in my project? The first has been there for a long time, the second was automatically added lately with the latest IntelliJ...
The inspection you mentioned created this second file ending in .classname! I remember now! But even though this file is now there, the inspection is still on - and nothing is to been seen in the Scripting Dialog.
image.png
So, I don't know how to get out of this endless loop. Inspection hints, you apply, nothing happens. And then, in secondary projects, where this DSL is just a dependency, I am not even sure how the script language is registered there...
v
is it the same project you already shared with me before? I want to check on my side; the idea of the window was like: you either can provide a definition name and when apply the idea will try to load it from some places (the .jar file you have, some sources under /kotlin/src), either you can provide a classpath to let idea automatically detect the definition (it will try to find the metafile that ends with .classname)
and the inspection should make at least one of this way work, but seems like it doesn't
o
It's always the same. And no, just putting the FQN of that class there and pressing apply does just nothing.
The inspection, when first used, created that resource file. But since then, the file is there but nothing changed.
v
did you also rebuild the project after the file was created?
o
Where do I find the logs regarding this activity?
v
I mean create a .jar that contains definition class and file name?
o
yes, many, many times. I am constantly working on that project
the jar is always created when building... or not? I mean, the secondary dev-project pulls that jar from a repo. So it's in the maven cache.
v
I acknowledge the problem is on our side. I'm gonna step out for an hour and then I'll test it on the trala script project on my side and get back to you, ok?
o
sure, please! thanks! would be great if it is just something I can fix...
v
we'll figure this out we can also setup a call/demo or something to make you unblocked if needed
❤️ 1
but first let me try the way you do
o
Greatly appreciated!
v
thanks for pinging
taking a look into your project
the only reproducer I've got is this: github.com/Zordid/kotlin-demo-dsl seems like I need a new one?
o
No, no, I could update it I guess. But see my DM!
🙌 1