Kotlin / Kotlin/kotlin-script-examples
cannot run main-kts scripts directly after cloning
- Dominant language
- Kotlin
- Stars
- 339
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
Straight running main.kts scripts is not working after cloning the repo
Running `jvm/main-kts/scripts/kotlin-shell.main.kts` directly gives the following compile time errors.
```sh
kotlin kotlin-shell.main.kts
kotlin-shell.main.kts:26:13: error: annotation argument must be a compile-time constant.
@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
^
kotlin-shell.main.kts:26:32: error: unresolved reference 'ExperimentalCoroutinesApi'.
@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
^
kotlin-shell.main.kts:30:44: error: unresolved reference 'shell'.
import eu.jrie.jetbrains.kotlinshell.shell.shell
^
kotlin-shell.main.kts:32:1: error: unresolved reference 'shell'.
shell {
^
kotlin-shell.main.kts:34:9: error: unresolved reference 'invoke'.
"echo this is 'ls -l' command for current directory: ${env("PWD")}"()
^
kotlin-shell.main.kts:34:64: error: unresolved reference 'env'.
"echo this is 'ls -l' command for current directory: ${env("PWD")}"()
^
kotlin-shell.main.kts:35:9: error: expression 'ls -l' of type 'String' cannot be invoked as a function. Function 'invoke()' is not found.
"ls -l"()
^
kotlin-shell.main.kts:43:9: error: unresolved reference 'pipeline'.
pipeline {
^
kotlin-shell.main.kts:44:30: error: unresolved reference 'process'.
"cat ${args[0]}".process() pipe
^
kotlin-shell.main.kts:45:21: error: unresolved reference 'streamLambda'.
streamLambda { strm, _, _ ->
^
kotlin-shell.main.kts:45:36: error: cannot infer type for value parameter 'strm'. Specify it explicitly.
streamLambda { strm, _, _ ->
^
kotlin-shell.main.kts:45:42: error: cannot infer type for implicit value parameter 'it'. Specify it explicitly.
streamLambda { strm, _, _ ->
^
kotlin-shell.main.kts:45:45: error: cannot infer type for implicit value parameter 'it'. Specify it explicitly.
streamLambda { strm, _, _ ->
^
kotlin-shell.main.kts:47:45: error: unresolved reference 'read'.
val byte = strm.read()
^
kotlin-shell.main.kts:66:9: error: unresolved reference 'invoke'.
"wc ${args[0]}"()
^
```
Am I running this the wrong way ?
Same for html script
```sh
kotlin kotlinx-html.main.kts
kotlinx-html.main.kts:18:28: error: unresolved reference 'createHTML'.
import kotlinx.html.stream.createHTML
^
kotlinx-html.main.kts:22:7: error: unresolved reference 'createHTML'.
print(createHTML().html {
^
kotlinx-html.main.kts:23:5: error: unresolved reference 'body'.
body {
^
kotlinx-html.main.kts:24:9: error: unresolved reference 'h1'.
h1 { +"Hello, $addressee!" }
^
kotlinx-html.main.kts:24:14: error: unresolved reference 'unaryPlus' for operator '+'.
h1 { +"Hello, $addressee!" }
^
```
Info
```sh
kotlin -version
Kotlin version 2.2.21-release-469 (JRE 25.0.1+8-27)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the commands against jvm/main-kts/scripts/kotlin-shell.main.kts and kotlinx-html.main.kts after cloning, then compare how their dependencies are provided. Trace the scripts' referenced Kotlin shell and kotlinx.html APIs; done means both examples run directly without the reported unresolved-reference and annotation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100