The -script option is still not working on M4


Little disappointed that this issue is not resolve for M4

It a useful great tool to let beginner to play with Kotlin. Not sure why priority is not in it. Shipping a broken “-script” option is not a good thing to let people to see, especially if they first time playing with it. If not ready, I would even recommend not to show it in help page.



The -script option doesn't seem to be broken. This works fine for me:


bin/kotlinc-jvm -script foo.ktscript

The exception in the report is a bad diagnostics on broke command line syntax, no more than that.


HI Andrey,

I tried with M4 and it’s still now working for me. Is there something I am doing wrong?

bash> bin/kotlinc-jvm -script Test.kt EXCEPTION: java.lang.RuntimeException: Failed to evaluate script: java.lang.NullPointerException   at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript( :265)   at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileAndExecuteScript(KotlinToJVMBytecodeCom   at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(   at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(   at org.jetbrains.jet.cli.common.CLICompiler.exec(   at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(   at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(   at org.jetbrains.jet.cli.common.CLICompiler.exec(   at org.jetbrains.jet.cli.common.CLICompiler.doMainNoExit(   at org.jetbrains.jet.cli.common.CLICompiler.doMain(   at org.jetbrains.jet.cli.jvm.K2JVMCompiler.main( Caused by: java.lang.NullPointerException   at org.jetbrains.jet.lang.resolve.ScriptNameUtil.classNameForScript(   at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileScript( :262)   ... 10 more

exec() finished with INTERNAL_ERROR return code

bash> bin/kotlinc-jvm -version
INFO: Kotlin Compiler version 0.4.297


Changing the file extension to .ktscript should help


Ah ha! Now that's a tricky requirement. Perhaps it should be a hint on the -help page? I would never guess that out.

Thanks Andrey. I will try out more on this -script feature now that I get it to work. :slight_smile: