Open johnsonlee opened 4 years ago
Copyright : 2020 Holger Brandl
License : MIT
Version : v2.9.3
Website : https://github.com/holgerbrandl/kscript
I've tried and it seems to work as intended
brandl@ubuntu2:~$ kscript kscript300.kts
[kscript] Resolving dependencies...
[kscript] Resolving com.android.tools.ddms:ddmlib:27.1.0...Done
[kscript] Resolving com.github.holgerbrandl:kscript-annotations:1.4...Done
[kscript] Dependencies resolved
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at Main_Kscript300$Companion.main(Main_Kscript300.kt:6)
at Main_Kscript300.main(Main_Kscript300.kt)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jetbrains.kotlin.runner.AbstractRunner.run(runners.kt:64)
at org.jetbrains.kotlin.runner.Main.run(Main.kt:149)
at org.jetbrains.kotlin.runner.Main.main(Main.kt:159)
Caused by: java.lang.IllegalStateException: application name is required
at Kscript300.<init>(kscript300.kts:71)
... 13 more
brandl@ubuntu2:~$ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (build 1.8.0_272-8u272-b10-0ubuntu1~20.04-b10)
OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
brandl@ubuntu2:~$ kotlin -version
Kotlin version 1.4.10-release-411 (JRE 1.8.0_272-8u272-b10-0ubuntu1~20.04-b10)
brandl@ubuntu2:~$
Could you check/provide the version of java and kotlin?
Java version:
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)
Kotlin versoin:
Kotlin version 1.4.10-release-411 (JRE 1.8.0_232-b09)
That's odd. Your settings seem to be identical to my setup and it works for me (see above).
To trace down the root cause of the problem, could you
1) clear the cache with kscript --clear-cache
. Does this fix script execution?
2) If not, could you temporarily move your maven cache to make sure that dependencies are correctly resolved:
mv ~/.m2 m2_tmp
kscript kscript300.kts
#restore m2
rm -rf ~/.m2
mv m2_temp ~/.m2
Nothing has changed
I've moved to kotlin script, it works well.
https://gist.github.com/johnsonlee/154671b11f7e8c068aa6966ac72aeb7f
Hmm, it works for me, and you have found another solution. So I think can solve the ticket then. Also, the new version v3 of kscript may solve the problem on your end as well.
Feel welcome to reopen the ticket if needed.
I've bumped into the same issue. This looks related to the file extension. I'm guessing kotlin/kotlinc do some specific handling for files ending with *.main.kts
and that doesn't play nice with kscript.
There is now a -howtorun
option that might or might not help...
Without howtorun it is indeed hard to handle.
I'm currently encountering this same issue when I do "kscript --idea myscript.main.kts".
Intellij shows this error. Anyone knows how to fix this error in the IDE?
ddms.main.kts