Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running the kotlin compiler #89

Open
jayvdb opened this issue Feb 11, 2023 · 3 comments
Open

Running the kotlin compiler #89

jayvdb opened this issue Feb 11, 2023 · 3 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Feb 11, 2023

The following doesn't work, because there is no (predictable) value which can be used to populate the -kotlin-home cli arg. Is there a way we can make this possible ? Some CLI arg substitution that can occur within jgo?

$ jgo --additional-endpoints org.jetbrains.kotlin:kotlin-stdlib org.jetbrains.kotlin:kotlin-compiler Foo.kt
INFO 2023-02-11 15:01:26,477: First time start-up may be slow. Downloaded dependencies will be cached for shorter start-up times in subsequent executions.
INFO 2023-02-11 15:01:28,947: Inferring main class from jar manifest
INFO 2023-02-11 15:01:29,021: Inferred main class: org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
warning: unable to find kotlin-stdlib.jar in the Kotlin home directory. Pass either '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
warning: unable to find kotlin-script-runtime.jar in the Kotlin home directory. Pass either '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
warning: unable to find kotlin-reflect.jar in the Kotlin home directory. Pass either '-no-reflect' or '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
Foo.kt:8:17: error: cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library
fun indexing(): Int {
                ^
@jayvdb
Copy link
Contributor Author

jayvdb commented Feb 11, 2023

fwiw, I also have the same problem with https://github.com/kscripting/kscript

$ jgo --additional-endpoints commons-cli:commons-cli org.jetbrains.kotlin:kotlin-scripting-jvm org.jetbrains.kotlin:kotlin-stdlib io.github.kscripting:shell io.github.kscripting:kscript:io.github.kscripting.kscript.KscriptKt linux Foo.kt
[kscript] [ERROR] KOTLIN_HOME is not set and could not be inferred from context.

@jayvdb
Copy link
Contributor Author

jayvdb commented Feb 18, 2023

Quite interestingly, using kotlin-compiler-embeddable also fails

> jgo --additional-endpoints org.jetbrains.kotlin:kotlin-stdlib org.jetbrains.kotlin:kotlin-compiler-embeddable:org.jetbrains.kotlin.cli.jvm.K2JVMCompiler path/to/script.kt 
warning: unable to find kotlin-stdlib.jar in the Kotlin home directory. Pass either '-no-stdlib' to prevent adding it to the classpath, or the correct '-kotlin-home'
...

@jayvdb
Copy link
Contributor Author

jayvdb commented Dec 30, 2023

kscript now works with KOTLIN_HOME set

jgo --additional-endpoints commons-cli:commons-cli commons-codec:commons-codec io.github.kscripting:shell io.github.kscripting:kscript:io.github.kscripting.kscript.KscriptKt linux tests/expected/print.kt

otherwise the error is

[kscript] [ERROR] KOTLIN_HOME is not set and could not be inferred from context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant