educative.io

Educative

Running kotlin as script

Following the “Compile to bytecode and run”

It mentioend a very simple code

#!/usr/bin/env kotlinc-jvm -script

println("hi")

I get the following result:

/usr/bin/env: ‘kotlinc-jvm -script’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

Searching around the web didn’t result in much, any thoughts?
I tried replacing the -S` and a few variations but no luck

PS: using the full path for kotlinc-jvm works as expected (according to the class).

I would like to understand a bit more about why the shebang behaves on that way.


Course: The Ultimate Guide to Kotlin Programming - Learn Interactively
Lesson: Compile to Bytecode and Run - The Ultimate Guide to Kotlin Programming