Piotr Krzemiński
02/20/2025, 1:00 PM@file:DependsOn("...")? 🙈 scripting would have to know where to look for the TOML file, and it's non-trivial to infer. It could traverse starting from the script's location, up the file tree, until it finds gradle/libs.versions.tomlPiotr Krzemiński
02/20/2025, 3:06 PM.github/workflows/end-to-end-tests.main.kts here: https://github.com/typesafegithub/github-workflows-kt/actions/runs/13436465865/job/37545104505?pr=1830 causes:
java.lang.NoClassDefFoundError: kotlinx/io/unsafe/UnsafeBufferOperations.
So far I checked that:
• @file:DependsOn("io.github.typesafegithub:action-updates-checker:3.2.1-SNAPSHOT") and any pieces that depend on functions from it, it works - so this package is to blame
• UnsafeBufferOperations was introduced in kotlinx-io 0.5.0
• ktor started using kotlinx-io starting 3.1.0 in this commit
Something must still depend on kotlinx-io older than 0.5.0, but I cannot pin it down...Rob Elliot
02/28/2025, 1:20 PMScriptCompilationConfiguration to require a specific return type for the script? So that the script will fail to compile if the last expression is not of that type?WayZer
03/29/2025, 2:50 PMobject TableVersion : IdTable<String>("TableVersion") {
// can't use `text` as h2db don't support for primaryKey
override val id: Column<EntityID<String>> = varchar("table", 64).entityId()
override val primaryKey: PrimaryKey = PrimaryKey(id) // h2database#2191
//...
}
will complain PrimaryKey class (inner class of Table) is not found.
This example works with -language-version=1.9zt
04/04/2025, 4:12 AMMETA-INF/kotlin/script/templates/dev.zt64.composables.ComposableScript but when I select the script nothing is resolved and the classpath is missing dependencies. I've tried adding isStandalone(false) to my compilation configuration as well
here is the repository https://github.com/zt64/compose-scriptsOlaf Gottschalk
04/25/2025, 5:41 AM@TransformationDsl
infix fun <D : Any, VO> SetOperation<S, D>.by(valueMapper: ValueMapper<Any?, VO>) =
apply { source = source.map(valueMapper) }
When this function is used in "normal IntelliJ" contexts, a call like this compiles and works just fine:
set optional "overallWeightTransportation" from "GrossWeightTransportationQuantity" by unitCodeMapper
If you look very closely to my generics, the generic type VO is not really relevant to this function, it has not bounds, the usage of the parameter valueMapper when passed to the map function does not care about this generic type, as map accepts everything.
I did not realize this was over-engineered until when compiled with the script compiler I got this error:
set optional "overallWeightTransportation" from "GrossWeightTransportationQuantity" by unitCodeMapper //later mandatory
^^ Cannot infer type for this parameter. Specify it explicitly.
^^ Not enough information to infer type argument for 'VO'.
The key question is now: why does it work just fine in IntelliJ, but not in scripting compilation?
Solution for my immediate problem was to replace VO with * of course... but the question remains... ;-)louiscad
05/05/2025, 12:34 AMritesh
05/09/2025, 3:11 PMDaniel Pitts
05/10/2025, 4:41 PMRob Elliot
05/24/2025, 7:36 PMAndrewStone
06/27/2025, 8:56 PMdarkmoon_uk
06/29/2025, 1:17 AM.kts scripts instead of `.sh`; keeping more complex scripts in a powerful, familiar language.
Unfortunately the usefulness of kts is unduly limited by IntelliJ IDE's failure to resolve symbols across @file:Import dependencies - this is an essential feature for composing scripts together e.g. importing some library functions from a common.kts - meanwhile the scripts still run fine, it's just IDE support that's lacking.
This problem has only become more impactful with junie Junie; as the agent sees 'unresolved' false positives and erroneously act upon them, struggling for a fix that never comes.
kodee sad This limitation is very sad, given it's been hanging for over 2 years...
KTIJ-16352 Scripts / IDE: unresolved reference when trying to import file in main.kts scripts with @Import annotation
Any insights into this issue in or outside of JB? Is scripting just abandoned beyond what's needed for Gradle? Such a shame, it's a killer feature in my book.Stylianos Gakis
07/04/2025, 2:35 PM- name: This works
run: echo SOME_VAR=asd >> $GITHUB_ENV
- name: Using it
run: echo $SOME_VAR
env:
SOME_VAR: ${{ env.SOME_VAR }}
And this works perfectly fine.
In Kotlin I try to do:
runCommand("echo SOME_VAR=asd >> \$GITHUB_ENV")
(where runCommand comes from here https://github.com/apollographql/apollo-kotlin/blob/65dd7a44a74ed016988777521248da164de32ea0/scripts/bump-kotlin-nightlies.main.kts#L71C1-L85C2 basically using ProcessBuilder)
And then I try to do the same exact Using it task, but nothing at all gets printed. The contents of SOME_VAR are just empty.
Is this some issue with ProcessBuilder, or something I am doing which is wrong here?embonnin
07/27/2025, 2:58 PM*.main.kts file? Like output or something? It won't import my dependencies but I'm unsure why...joseph_ivie
07/28/2025, 3:27 PM*.main.kts? It would be incredibly useful.Olaf Gottschalk
08/01/2025, 5:10 AMBasicScriptingHost.eval(...) function to run script code, is there any way, a script can programmatically add elements to the reports property of the ResultWithDiagnostics that it returns?
In some situations that are caught at runtime of my script, I want to return a warning just like a compiler warning, but my script can only detect this at runtime like when a user does something they are not intended to do. My current "solution" is to log a warning using a logger... but this is really not what I want. I need this information as a side-information along with the result of the script evaluation. So, ideally, in my script, I would like to call a function that adds elements to this collection of ScriptDiagnostic elements with a severity of warning...
Is that possible?Tim Putnam
08/05/2025, 8:30 PMBasicJvmScriptingHost embedded in an application that's dynamically loading JPMS modules using ModuleLayer.
I simply want the classloader from this ModuleLayer to be visible to the compiler. I"m setting baseClassLoader in the host configuration thus:
val hostconf = ScriptingHostConfiguration {
jvm {
baseClassLoader(appClassloader)
}
}
I've also tried a variety of ways to set the classloader in the ScriptCompilationConfiguration but to no avail. I don't want to add explicit jars (e.g. dependenciesFromClassloader() ). I just want it to use a provided classloader, but it always just uses the main/boot classloader.
This is something I've had working at some stage in the pass, but now doesn't seem to.
I feel like I'm missing something obvious - it seems to want external files? Please, any pointers?darkmoon_uk
08/23/2025, 12:02 AM.kts files instead of Bash, to perform more complex steps; like preparing ECS Deployment tasks.
The good news is - GitHub Actions images already include kotlin, so no complex preparation steps, just run: kotlin myScript.main.kts and off you go! kodee happyPaul Woitaschek
09/07/2025, 5:10 PMmikehearn
09/15/2025, 12:58 PMmikehearn
09/15/2025, 1:54 PM@file:DependsOn unless you do this because correct resolution of those artifacts requires Maven model building. There are likely other edge cases too.
Please note that I didn't bother implementing any support for options as I don't use them. But it should be easy enough to see how to do it.
Hope that helps!Primoz Delopst
09/16/2025, 9:08 PMPrimoz Delopst
09/26/2025, 6:36 AMy9san9
09/27/2025, 5:24 PMS.
10/11/2025, 3:21 PMShaun Wild
10/24/2025, 11:37 AMShaun Wild
10/24/2025, 5:38 PMShaun Wild
10/25/2025, 4:15 PMColton Idle
10/28/2025, 3:11 PMCaleb Miles
10/30/2025, 7:41 PMrefineConfiguration#onAnnotations
We would like to just implement the basic DependsOn,Repository,Import,and CompilerOptions however whenever I specify annotations in onAnnotations I get this:
unable to load class kotlin.script.experimental.dependencies.DependsOn. It seems to error on whichever annotation is first in the list. For the life of me I cannot figure this out.
refineConfiguration {
onAnnotations(DependsOn::class, Repository::class, Import::class, CompilerOptions::class, handler = AnnotationProcessor())
}
I can send a link to the repo if needed 🙂
Any help is much appreciated.